mirror of
https://github.com/gookit/cache.git
synced 2025-09-26 20:21:16 +08:00
⬆️ dep(go): replace all interface{} to any, will not support on go < 1.18
This commit is contained in:
@@ -57,12 +57,12 @@ All cache driver implemented the `cache.Cache` interface. So, You can add any cu
|
|||||||
type Cache interface {
|
type Cache interface {
|
||||||
// basic operation
|
// basic operation
|
||||||
Has(key string) bool
|
Has(key string) bool
|
||||||
Get(key string) interface{}
|
Get(key string) any
|
||||||
Set(key string, val interface{}, ttl time.Duration) (err error)
|
Set(key string, val any, ttl time.Duration) (err error)
|
||||||
Del(key string) error
|
Del(key string) error
|
||||||
// multi operation
|
// multi operation
|
||||||
GetMulti(keys []string) map[string]interface{}
|
GetMulti(keys []string) map[string]any
|
||||||
SetMulti(values map[string]interface{}, ttl time.Duration) (err error)
|
SetMulti(values map[string]any, ttl time.Duration) (err error)
|
||||||
DelMulti(keys []string) error
|
DelMulti(keys []string) error
|
||||||
// clear and close
|
// clear and close
|
||||||
Clear() error
|
Clear() error
|
||||||
|
@@ -55,12 +55,12 @@ go get github.com/gookit/cache
|
|||||||
type Cache interface {
|
type Cache interface {
|
||||||
// basic op
|
// basic op
|
||||||
Has(key string) bool
|
Has(key string) bool
|
||||||
Get(key string) interface{}
|
Get(key string) any
|
||||||
Set(key string, val interface{}, ttl time.Duration) (err error)
|
Set(key string, val any, ttl time.Duration) (err error)
|
||||||
Del(key string) error
|
Del(key string) error
|
||||||
// multi op
|
// multi op
|
||||||
GetMulti(keys []string) map[string]interface{}
|
GetMulti(keys []string) map[string]any
|
||||||
SetMulti(values map[string]interface{}, ttl time.Duration) (err error)
|
SetMulti(values map[string]any, ttl time.Duration) (err error)
|
||||||
DelMulti(keys []string) error
|
DelMulti(keys []string) error
|
||||||
// clear & close
|
// clear & close
|
||||||
Clear() error
|
Clear() error
|
||||||
|
@@ -19,11 +19,11 @@ func (c *BadgerDB) Has(key string) bool {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BadgerDB) Get(key string) interface{} {
|
func (c *BadgerDB) Get(key string) any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BadgerDB) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *BadgerDB) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,11 +31,11 @@ func (c *BadgerDB) Del(key string) error {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BadgerDB) GetMulti(keys []string) map[string]interface{} {
|
func (c *BadgerDB) GetMulti(keys []string) map[string]any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BadgerDB) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *BadgerDB) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,8 +38,8 @@ func (c *BoltDB) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (c *BoltDB) Get(key string) interface{} {
|
func (c *BoltDB) Get(key string) any {
|
||||||
var val interface{}
|
var val any
|
||||||
err := c.db.View(func(tx *bbolt.Tx) error {
|
err := c.db.View(func(tx *bbolt.Tx) error {
|
||||||
b := tx.Bucket([]byte(c.Bucket))
|
b := tx.Bucket([]byte(c.Bucket))
|
||||||
bs := b.Get([]byte(key))
|
bs := b.Get([]byte(key))
|
||||||
@@ -58,7 +58,7 @@ func (c *BoltDB) Get(key string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func (c *BoltDB) Set(key string, val interface{}, _ time.Duration) (err error) {
|
func (c *BoltDB) Set(key string, val any, _ time.Duration) (err error) {
|
||||||
bts, err := c.MustMarshal(val)
|
bts, err := c.MustMarshal(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -77,12 +77,12 @@ func (c *BoltDB) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by multi key
|
// GetMulti values by multi key
|
||||||
func (c *BoltDB) GetMulti(keys []string) map[string]interface{} {
|
func (c *BoltDB) GetMulti(keys []string) map[string]any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values by multi key
|
// SetMulti values by multi key
|
||||||
func (c *BoltDB) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *BoltDB) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
// Name driver name
|
// Name driver name
|
||||||
const Name = "buntDB"
|
const Name = "buntDB"
|
||||||
|
|
||||||
// Memory open a file that does not persist to disk.
|
// Memory open a file that does not persist to disk.
|
||||||
const Memory = ":memory:"
|
const Memory = ":memory:"
|
||||||
|
|
||||||
@@ -65,8 +66,8 @@ func (c *BuntDB) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (c *BuntDB) Get(key string) interface{} {
|
func (c *BuntDB) Get(key string) any {
|
||||||
var val interface{}
|
var val any
|
||||||
err := c.db.View(func(tx *buntdb.Tx) error {
|
err := c.db.View(func(tx *buntdb.Tx) error {
|
||||||
str, err := tx.Get(key, false)
|
str, err := tx.Get(key, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -83,7 +84,7 @@ func (c *BuntDB) Get(key string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func (c *BuntDB) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *BuntDB) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
bts, err := c.MustMarshal(val)
|
bts, err := c.MustMarshal(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -110,8 +111,8 @@ func (c *BuntDB) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by multi key
|
// GetMulti values by multi key
|
||||||
func (c *BuntDB) GetMulti(keys []string) map[string]interface{} {
|
func (c *BuntDB) GetMulti(keys []string) map[string]any {
|
||||||
results := make(map[string]interface{}, len(keys))
|
results := make(map[string]any, len(keys))
|
||||||
err := c.db.View(func(tx *buntdb.Tx) error {
|
err := c.db.View(func(tx *buntdb.Tx) error {
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
str, err := tx.Get(key, false)
|
str, err := tx.Get(key, false)
|
||||||
@@ -119,7 +120,7 @@ func (c *BuntDB) GetMulti(keys []string) map[string]interface{} {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var val interface{}
|
var val any
|
||||||
err = c.UnmarshalTo([]byte(str), &val)
|
err = c.UnmarshalTo([]byte(str), &val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -138,7 +139,7 @@ func (c *BuntDB) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values by multi key
|
// SetMulti values by multi key
|
||||||
func (c *BuntDB) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *BuntDB) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
return c.db.Update(func(tx *buntdb.Tx) (err error) {
|
return c.db.Update(func(tx *buntdb.Tx) (err error) {
|
||||||
opt := &buntdb.SetOptions{}
|
opt := &buntdb.SetOptions{}
|
||||||
if ttl > 0 {
|
if ttl > 0 {
|
||||||
|
11
cache.go
11
cache.go
@@ -99,7 +99,8 @@ func UnregisterAll(fn ...func(cache Cache)) int {
|
|||||||
|
|
||||||
// SetDefName set default driver name.
|
// SetDefName set default driver name.
|
||||||
// Deprecated
|
// Deprecated
|
||||||
// please use DefaultUse() instead it
|
//
|
||||||
|
// please use DefaultUse() instead it
|
||||||
func SetDefName(driverName string) {
|
func SetDefName(driverName string) {
|
||||||
std.DefaultUse(driverName)
|
std.DefaultUse(driverName)
|
||||||
}
|
}
|
||||||
@@ -159,12 +160,12 @@ func Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func Get(key string) interface{} {
|
func Get(key string) any {
|
||||||
return std.Default().Get(key)
|
return std.Default().Get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func Set(key string, val interface{}, ttl time.Duration) error {
|
func Set(key string, val any, ttl time.Duration) error {
|
||||||
return std.Default().Set(key, val, ttl)
|
return std.Default().Set(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,12 +175,12 @@ func Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by keys
|
// GetMulti values by keys
|
||||||
func GetMulti(keys []string) map[string]interface{} {
|
func GetMulti(keys []string) map[string]any {
|
||||||
return std.Default().GetMulti(keys)
|
return std.Default().GetMulti(keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values
|
// SetMulti values
|
||||||
func SetMulti(mv map[string]interface{}, ttl time.Duration) error {
|
func SetMulti(mv map[string]any, ttl time.Duration) error {
|
||||||
return std.Default().SetMulti(mv, ttl)
|
return std.Default().SetMulti(mv, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
driver.go
30
driver.go
@@ -9,10 +9,10 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
// MarshalFunc define
|
// MarshalFunc define
|
||||||
MarshalFunc func(v interface{}) ([]byte, error)
|
MarshalFunc func(v any) ([]byte, error)
|
||||||
|
|
||||||
// UnmarshalFunc define
|
// UnmarshalFunc define
|
||||||
UnmarshalFunc func(data []byte, v interface{}) error
|
UnmarshalFunc func(data []byte, v any) error
|
||||||
)
|
)
|
||||||
|
|
||||||
// data (Un)marshal func
|
// data (Un)marshal func
|
||||||
@@ -20,7 +20,7 @@ var (
|
|||||||
Marshal MarshalFunc = json.Marshal
|
Marshal MarshalFunc = json.Marshal
|
||||||
Unmarshal UnmarshalFunc = json.Unmarshal
|
Unmarshal UnmarshalFunc = json.Unmarshal
|
||||||
|
|
||||||
errNoMarshal = errors.New("must set Marshal func")
|
errNoMarshal = errors.New("must set Marshal func")
|
||||||
errNoUnmarshal = errors.New("must set Unmarshal func")
|
errNoUnmarshal = errors.New("must set Unmarshal func")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,21 +47,21 @@ type BaseDriver struct {
|
|||||||
|
|
||||||
// WithDebug add option: debug
|
// WithDebug add option: debug
|
||||||
func WithDebug(debug bool) func(opt *Option) {
|
func WithDebug(debug bool) func(opt *Option) {
|
||||||
return func (opt *Option) {
|
return func(opt *Option) {
|
||||||
opt.Debug = debug
|
opt.Debug = debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithEncode add option: encode
|
// WithEncode add option: encode
|
||||||
func WithEncode(encode bool) func(opt *Option) {
|
func WithEncode(encode bool) func(opt *Option) {
|
||||||
return func (opt *Option) {
|
return func(opt *Option) {
|
||||||
opt.Encode = encode
|
opt.Encode = encode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPrefix add option: prefix
|
// WithPrefix add option: prefix
|
||||||
func WithPrefix(prefix string) func(opt *Option) {
|
func WithPrefix(prefix string) func(opt *Option) {
|
||||||
return func (opt *Option) {
|
return func(opt *Option) {
|
||||||
opt.Prefix = prefix
|
opt.Prefix = prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ func (l *BaseDriver) WithOptions(optFns ...func(option *Option)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MustMarshal cache value
|
// MustMarshal cache value
|
||||||
func (l *BaseDriver) MustMarshal(val interface{}) ([]byte, error) {
|
func (l *BaseDriver) MustMarshal(val any) ([]byte, error) {
|
||||||
if Marshal == nil {
|
if Marshal == nil {
|
||||||
return nil, errNoMarshal
|
return nil, errNoMarshal
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ func (l *BaseDriver) MustMarshal(val interface{}) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Marshal cache value
|
// Marshal cache value
|
||||||
func (l *BaseDriver) Marshal(val interface{}) (interface{}, error) {
|
func (l *BaseDriver) Marshal(val any) (any, error) {
|
||||||
if l.opt.Encode && Marshal != nil {
|
if l.opt.Encode && Marshal != nil {
|
||||||
return Marshal(val)
|
return Marshal(val)
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ func (l *BaseDriver) Marshal(val interface{}) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalTo cache value
|
// UnmarshalTo cache value
|
||||||
func (l *BaseDriver) UnmarshalTo(bts []byte, ptr interface{}) error {
|
func (l *BaseDriver) UnmarshalTo(bts []byte, ptr any) error {
|
||||||
if Unmarshal == nil {
|
if Unmarshal == nil {
|
||||||
return errNoUnmarshal
|
return errNoUnmarshal
|
||||||
}
|
}
|
||||||
@@ -99,13 +99,13 @@ func (l *BaseDriver) UnmarshalTo(bts []byte, ptr interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal cache value
|
// Unmarshal cache value
|
||||||
func (l *BaseDriver) Unmarshal(val []byte, err error) interface{} {
|
func (l *BaseDriver) Unmarshal(val []byte, err error) any {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.SetLastErr(err)
|
l.SetLastErr(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var newV interface{}
|
var newV any
|
||||||
if l.opt.Encode && Unmarshal != nil {
|
if l.opt.Encode && Unmarshal != nil {
|
||||||
err := Unmarshal(val, &newV)
|
err := Unmarshal(val, &newV)
|
||||||
l.SetLastErr(err)
|
l.SetLastErr(err)
|
||||||
@@ -129,23 +129,23 @@ func (l *BaseDriver) BuildKeys(keys []string) []string {
|
|||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
|
|
||||||
rks := make([]string,0, len(keys))
|
rks := make([]string, 0, len(keys))
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
rks = append(rks, l.opt.Prefix + key)
|
rks = append(rks, l.opt.Prefix+key)
|
||||||
}
|
}
|
||||||
return rks
|
return rks
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugf print an debug message
|
// Debugf print an debug message
|
||||||
func (l *BaseDriver) Debugf(format string, v ...interface{}) {
|
func (l *BaseDriver) Debugf(format string, v ...any) {
|
||||||
if l.opt.Debug && l.opt.Logger != nil {
|
if l.opt.Debug && l.opt.Logger != nil {
|
||||||
l.opt.Logger.Printf(format, v...)
|
l.opt.Logger.Printf(format, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logf print an log message
|
// Logf print an log message
|
||||||
func (l *BaseDriver) Logf(format string, v ...interface{}) {
|
func (l *BaseDriver) Logf(format string, v ...any) {
|
||||||
if l.opt.Logger != nil {
|
if l.opt.Logger != nil {
|
||||||
l.opt.Logger.Printf(format, v...)
|
l.opt.Logger.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
@@ -55,14 +55,14 @@ func (c *FileCache) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (c *FileCache) Get(key string) interface{} {
|
func (c *FileCache) Get(key string) any {
|
||||||
c.lock.RLock()
|
c.lock.RLock()
|
||||||
defer c.lock.RUnlock()
|
defer c.lock.RUnlock()
|
||||||
|
|
||||||
return c.get(key)
|
return c.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FileCache) get(key string) interface{} {
|
func (c *FileCache) get(key string) any {
|
||||||
// read cache from memory
|
// read cache from memory
|
||||||
if val := c.MemoryCache.get(key); val != nil {
|
if val := c.MemoryCache.get(key); val != nil {
|
||||||
return val
|
return val
|
||||||
@@ -92,14 +92,14 @@ func (c *FileCache) get(key string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func (c *FileCache) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *FileCache) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
return c.set(key, val, ttl)
|
return c.set(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FileCache) set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *FileCache) set(key string, val any, ttl time.Duration) (err error) {
|
||||||
err = c.MemoryCache.set(key, val, ttl)
|
err = c.MemoryCache.set(key, val, ttl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -151,11 +151,11 @@ func (c *FileCache) del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by multi key
|
// GetMulti values by multi key
|
||||||
func (c *FileCache) GetMulti(keys []string) map[string]interface{} {
|
func (c *FileCache) GetMulti(keys []string) map[string]any {
|
||||||
c.lock.RLock()
|
c.lock.RLock()
|
||||||
defer c.lock.RUnlock()
|
defer c.lock.RUnlock()
|
||||||
|
|
||||||
data := make(map[string]interface{}, len(keys))
|
data := make(map[string]any, len(keys))
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
data[key] = c.get(key)
|
data[key] = c.get(key)
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ func (c *FileCache) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values by multi key
|
// SetMulti values by multi key
|
||||||
func (c *FileCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *FileCache) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ type Item struct {
|
|||||||
// Exp expire time
|
// Exp expire time
|
||||||
Exp int64
|
Exp int64
|
||||||
// Val cache value storage
|
// Val cache value storage
|
||||||
Val interface{}
|
Val any
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expired check whether expired
|
// Expired check whether expired
|
||||||
@@ -44,14 +44,14 @@ func (c *MemoryCache) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get cache value by key
|
// Get cache value by key
|
||||||
func (c *MemoryCache) Get(key string) interface{} {
|
func (c *MemoryCache) Get(key string) any {
|
||||||
c.lock.RLock()
|
c.lock.RLock()
|
||||||
defer c.lock.RUnlock()
|
defer c.lock.RUnlock()
|
||||||
|
|
||||||
return c.get(key)
|
return c.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MemoryCache) get(key string) interface{} {
|
func (c *MemoryCache) get(key string) any {
|
||||||
if item, ok := c.caches[key]; ok {
|
if item, ok := c.caches[key]; ok {
|
||||||
// check expire time. if has been expired, remove it.
|
// check expire time. if has been expired, remove it.
|
||||||
if item.Expired() {
|
if item.Expired() {
|
||||||
@@ -66,14 +66,14 @@ func (c *MemoryCache) get(key string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set cache value by key
|
// Set cache value by key
|
||||||
func (c *MemoryCache) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *MemoryCache) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
return c.set(key, val, ttl)
|
return c.set(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MemoryCache) set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *MemoryCache) set(key string, val any, ttl time.Duration) (err error) {
|
||||||
item := &Item{Val: val}
|
item := &Item{Val: val}
|
||||||
if ttl > 0 {
|
if ttl > 0 {
|
||||||
item.Exp = time.Now().Unix() + int64(ttl/time.Second)
|
item.Exp = time.Now().Unix() + int64(ttl/time.Second)
|
||||||
@@ -100,10 +100,10 @@ func (c *MemoryCache) del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by multi key
|
// GetMulti values by multi key
|
||||||
func (c *MemoryCache) GetMulti(keys []string) map[string]interface{} {
|
func (c *MemoryCache) GetMulti(keys []string) map[string]any {
|
||||||
c.lock.RLock()
|
c.lock.RLock()
|
||||||
|
|
||||||
data := make(map[string]interface{}, len(keys))
|
data := make(map[string]any, len(keys))
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
data[key] = c.get(key)
|
data[key] = c.get(key)
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ func (c *MemoryCache) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values by multi key
|
// SetMulti values by multi key
|
||||||
func (c *MemoryCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *MemoryCache) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
for key, val := range values {
|
for key, val := range values {
|
||||||
if err = c.set(key, val, ttl); err != nil {
|
if err = c.set(key, val, ttl); err != nil {
|
||||||
|
@@ -45,13 +45,13 @@ func (g *GCache) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get cache by key
|
// Get cache by key
|
||||||
func (g *GCache) Get(key string) interface{} {
|
func (g *GCache) Get(key string) any {
|
||||||
val, _ := g.db.Get(key)
|
val, _ := g.db.Get(key)
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set cache by key
|
// Set cache by key
|
||||||
func (g *GCache) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (g *GCache) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
return g.db.SetWithExpire(key, val, ttl)
|
return g.db.SetWithExpire(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ func (g *GCache) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti cache by keys
|
// GetMulti cache by keys
|
||||||
func (g *GCache) GetMulti(keys []string) map[string]interface{} {
|
func (g *GCache) GetMulti(keys []string) map[string]any {
|
||||||
data := make(map[string]interface{}, len(keys))
|
data := make(map[string]any, len(keys))
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
val, err := g.db.Get(key)
|
val, err := g.db.Get(key)
|
||||||
@@ -76,7 +76,7 @@ func (g *GCache) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti cache by keys
|
// SetMulti cache by keys
|
||||||
func (g *GCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (g *GCache) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
for key, val := range values {
|
for key, val := range values {
|
||||||
err = g.db.SetWithExpire(key, val, ttl)
|
err = g.db.SetWithExpire(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
// base on the package: github.com/patrickmn/go-cache
|
// base on the package: github.com/patrickmn/go-cache
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
|
//
|
||||||
// import "github.com/gookit/cache"
|
// import "github.com/gookit/cache"
|
||||||
//
|
//
|
||||||
// cache.Register(gocache.NewGoCache(0, cache.FiveMinutes))
|
// cache.Register(gocache.NewGoCache(0, cache.FiveMinutes))
|
||||||
@@ -63,7 +64,7 @@ func (g *GoCache) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get cache by key
|
// Get cache by key
|
||||||
func (g *GoCache) Get(key string) interface{} {
|
func (g *GoCache) Get(key string) any {
|
||||||
if g.expireManually {
|
if g.expireManually {
|
||||||
g.db.DeleteExpired()
|
g.db.DeleteExpired()
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,7 @@ func (g *GoCache) Get(key string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set cache by key
|
// Set cache by key
|
||||||
func (g *GoCache) Set(key string, val interface{}, ttl time.Duration) error {
|
func (g *GoCache) Set(key string, val any, ttl time.Duration) error {
|
||||||
g.db.Set(key, val, ttl)
|
g.db.Set(key, val, ttl)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -85,8 +86,8 @@ func (g GoCache) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti cache by keys
|
// GetMulti cache by keys
|
||||||
func (g *GoCache) GetMulti(keys []string) map[string]interface{} {
|
func (g *GoCache) GetMulti(keys []string) map[string]any {
|
||||||
data := make(map[string]interface{}, len(keys))
|
data := make(map[string]any, len(keys))
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
val, ok := g.db.Get(key)
|
val, ok := g.db.Get(key)
|
||||||
@@ -99,7 +100,7 @@ func (g *GoCache) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti cache by keys
|
// SetMulti cache by keys
|
||||||
func (g GoCache) SetMulti(values map[string]interface{}, ttl time.Duration) error {
|
func (g GoCache) SetMulti(values map[string]any, ttl time.Duration) error {
|
||||||
for key, val := range values {
|
for key, val := range values {
|
||||||
g.db.Set(key, val, ttl)
|
g.db.Set(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
@@ -100,14 +100,14 @@ func (c *GoRedis) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get cache by key
|
// Get cache by key
|
||||||
func (c *GoRedis) Get(key string) interface{} {
|
func (c *GoRedis) Get(key string) any {
|
||||||
bts, err := c.rdb.Get(c.ctx, c.Key(key)).Bytes()
|
bts, err := c.rdb.Get(c.ctx, c.Key(key)).Bytes()
|
||||||
|
|
||||||
return c.Unmarshal(bts, err)
|
return c.Unmarshal(bts, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAs get cache and unmarshal to ptr
|
// GetAs get cache and unmarshal to ptr
|
||||||
func (c *GoRedis) GetAs(key string, ptr interface{}) error {
|
func (c *GoRedis) GetAs(key string, ptr any) error {
|
||||||
bts, err := c.rdb.Get(c.ctx, c.Key(key)).Bytes()
|
bts, err := c.rdb.Get(c.ctx, c.Key(key)).Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -117,7 +117,7 @@ func (c *GoRedis) GetAs(key string, ptr interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set cache by key
|
// Set cache by key
|
||||||
func (c *GoRedis) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *GoRedis) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
val, err = c.Marshal(val)
|
val, err = c.Marshal(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -132,12 +132,12 @@ func (c *GoRedis) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti cache by keys
|
// GetMulti cache by keys
|
||||||
func (c *GoRedis) GetMulti(keys []string) map[string]interface{} {
|
func (c *GoRedis) GetMulti(keys []string) map[string]any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti cache by keys
|
// SetMulti cache by keys
|
||||||
func (c *GoRedis) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *GoRedis) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,13 +6,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// BindStruct get cache value and map to a struct
|
// BindStruct get cache value and map to a struct
|
||||||
func BindStruct(val interface{}, ptr interface{}) error {
|
func BindStruct(val any, ptr any) error {
|
||||||
// val must convert to byte
|
// val must convert to byte
|
||||||
return Unmarshal(val.([]byte), ptr)
|
return Unmarshal(val.([]byte), ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GobDecode decode data by gob.Decode
|
// GobDecode decode data by gob.Decode
|
||||||
func GobDecode(bts []byte, ptr interface{}) error {
|
func GobDecode(bts []byte, ptr any) error {
|
||||||
buf := bytes.NewBuffer(bts)
|
buf := bytes.NewBuffer(bts)
|
||||||
dec := gob.NewDecoder(buf)
|
dec := gob.NewDecoder(buf)
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ func GobDecode(bts []byte, ptr interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GobEncode encode data by gob.Encode
|
// GobEncode encode data by gob.Encode
|
||||||
func GobEncode(val interface{}) (bs []byte, err error) {
|
func GobEncode(val any) (bs []byte, err error) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
enc := gob.NewEncoder(buf)
|
enc := gob.NewEncoder(buf)
|
||||||
if err = enc.Encode(val); err != nil {
|
if err = enc.Encode(val); err != nil {
|
||||||
|
@@ -20,11 +20,11 @@ func (c *LevelDB) Has(key string) bool {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LevelDB) Get(key string) interface{} {
|
func (c *LevelDB) Get(key string) any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LevelDB) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *LevelDB) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,11 +32,11 @@ func (c *LevelDB) Del(key string) error {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LevelDB) GetMulti(keys []string) map[string]interface{} {
|
func (c *LevelDB) GetMulti(keys []string) map[string]any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LevelDB) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *LevelDB) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
manager.go
11
manager.go
@@ -59,7 +59,8 @@ func (m *Manager) Unregister(name string) int {
|
|||||||
|
|
||||||
// SetDefName set default driver name. alias of DefaultUse()
|
// SetDefName set default driver name. alias of DefaultUse()
|
||||||
// Deprecated
|
// Deprecated
|
||||||
// please use DefaultUse() instead it
|
//
|
||||||
|
// please use DefaultUse() instead it
|
||||||
func (m *Manager) SetDefName(driverName string) {
|
func (m *Manager) SetDefName(driverName string) {
|
||||||
m.DefaultUse(driverName)
|
m.DefaultUse(driverName)
|
||||||
}
|
}
|
||||||
@@ -145,12 +146,12 @@ func (m *Manager) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (m *Manager) Get(key string) interface{} {
|
func (m *Manager) Get(key string) any {
|
||||||
return m.Default().Get(key)
|
return m.Default().Get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func (m *Manager) Set(key string, val interface{}, ttl time.Duration) error {
|
func (m *Manager) Set(key string, val any, ttl time.Duration) error {
|
||||||
return m.Default().Set(key, val, ttl)
|
return m.Default().Set(key, val, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,12 +161,12 @@ func (m *Manager) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by keys
|
// GetMulti values by keys
|
||||||
func (m *Manager) GetMulti(keys []string) map[string]interface{} {
|
func (m *Manager) GetMulti(keys []string) map[string]any {
|
||||||
return m.Default().GetMulti(keys)
|
return m.Default().GetMulti(keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values
|
// SetMulti values
|
||||||
func (m *Manager) SetMulti(mv map[string]interface{}, ttl time.Duration) error {
|
func (m *Manager) SetMulti(mv map[string]any, ttl time.Duration) error {
|
||||||
return m.Default().SetMulti(mv, ttl)
|
return m.Default().SetMulti(mv, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ func (c *MemCached) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (c *MemCached) Get(key string) (val interface{}) {
|
func (c *MemCached) Get(key string) (val any) {
|
||||||
item, err := c.client.Get(c.Key(key))
|
item, err := c.client.Get(c.Key(key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -61,7 +61,7 @@ func (c *MemCached) Get(key string) (val interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func (c *MemCached) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *MemCached) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
bts, err := c.MustMarshal(val)
|
bts, err := c.MustMarshal(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -81,7 +81,7 @@ func (c *MemCached) Del(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by multi key
|
// GetMulti values by multi key
|
||||||
func (c *MemCached) GetMulti(keys []string) map[string]interface{} {
|
func (c *MemCached) GetMulti(keys []string) map[string]any {
|
||||||
keys = c.BuildKeys(keys)
|
keys = c.BuildKeys(keys)
|
||||||
|
|
||||||
items, err := c.client.GetMulti(keys)
|
items, err := c.client.GetMulti(keys)
|
||||||
@@ -89,9 +89,9 @@ func (c *MemCached) GetMulti(keys []string) map[string]interface{} {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
values := make(map[string]interface{}, len(keys))
|
values := make(map[string]any, len(keys))
|
||||||
for key, item := range items {
|
for key, item := range items {
|
||||||
var val interface{}
|
var val any
|
||||||
if err := c.UnmarshalTo(item.Value, &val); err != nil {
|
if err := c.UnmarshalTo(item.Value, &val); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ func (c *MemCached) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values by multi key
|
// SetMulti values by multi key
|
||||||
func (c *MemCached) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *MemCached) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
for key, val := range values {
|
for key, val := range values {
|
||||||
if err = c.Set(c.Key(key), val, ttl); err != nil {
|
if err = c.Set(c.Key(key), val, ttl); err != nil {
|
||||||
return
|
return
|
||||||
|
@@ -17,11 +17,11 @@ func (c *NutsDB) Has(key string) bool {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *NutsDB) Get(key string) interface{} {
|
func (c *NutsDB) Get(key string) any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *NutsDB) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *NutsDB) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,11 +29,11 @@ func (c *NutsDB) Del(key string) error {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *NutsDB) GetMulti(keys []string) map[string]interface{} {
|
func (c *NutsDB) GetMulti(keys []string) map[string]any {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *NutsDB) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *NutsDB) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,14 +56,14 @@ func (c *Redigo) Connect() *Redigo {
|
|||||||
*************************************************************/
|
*************************************************************/
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (c *Redigo) Get(key string) interface{} {
|
func (c *Redigo) Get(key string) any {
|
||||||
bts, err := redis.Bytes(c.exec("Get", c.Key(key)))
|
bts, err := redis.Bytes(c.exec("Get", c.Key(key)))
|
||||||
|
|
||||||
return c.Unmarshal(bts, err)
|
return c.Unmarshal(bts, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAs get cache and unmarshal to ptr
|
// GetAs get cache and unmarshal to ptr
|
||||||
func (c *Redigo) GetAs(key string, ptr interface{}) error {
|
func (c *Redigo) GetAs(key string, ptr any) error {
|
||||||
bts, err := redis.Bytes(c.exec("Get", c.Key(key)))
|
bts, err := redis.Bytes(c.exec("Get", c.Key(key)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -73,7 +73,7 @@ func (c *Redigo) GetAs(key string, ptr interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set value by key
|
// Set value by key
|
||||||
func (c *Redigo) Set(key string, val interface{}, ttl time.Duration) (err error) {
|
func (c *Redigo) Set(key string, val any, ttl time.Duration) (err error) {
|
||||||
val, err = c.Marshal(val)
|
val, err = c.Marshal(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -99,11 +99,11 @@ func (c *Redigo) Has(key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMulti values by keys
|
// GetMulti values by keys
|
||||||
func (c *Redigo) GetMulti(keys []string) map[string]interface{} {
|
func (c *Redigo) GetMulti(keys []string) map[string]any {
|
||||||
conn := c.pool.Get()
|
conn := c.pool.Get()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
args := make([]interface{}, 0, len(keys))
|
args := make([]any, 0, len(keys))
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
args = append(args, c.Key(key))
|
args = append(args, c.Key(key))
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ func (c *Redigo) GetMulti(keys []string) map[string]interface{} {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
values := make(map[string]interface{}, len(keys))
|
values := make(map[string]any, len(keys))
|
||||||
for i, val := range list {
|
for i, val := range list {
|
||||||
values[keys[i]] = val
|
values[keys[i]] = val
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ func (c *Redigo) GetMulti(keys []string) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMulti values
|
// SetMulti values
|
||||||
func (c *Redigo) SetMulti(values map[string]interface{}, ttl time.Duration) (err error) {
|
func (c *Redigo) SetMulti(values map[string]any, ttl time.Duration) (err error) {
|
||||||
conn := c.pool.Get()
|
conn := c.pool.Get()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ func (c *Redigo) SetMulti(values map[string]interface{}, ttl time.Duration) (err
|
|||||||
|
|
||||||
// DelMulti values by keys
|
// DelMulti values by keys
|
||||||
func (c *Redigo) DelMulti(keys []string) (err error) {
|
func (c *Redigo) DelMulti(keys []string) (err error) {
|
||||||
args := make([]interface{}, 0, len(keys))
|
args := make([]any, 0, len(keys))
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
args = append(args, c.Key(key))
|
args = append(args, c.Key(key))
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ func (c *Redigo) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// actually do the redis cmds, args[0] must be the key name.
|
// actually do the redis cmds, args[0] must be the key name.
|
||||||
func (c *Redigo) exec(commandName string, args ...interface{}) (reply interface{}, err error) {
|
func (c *Redigo) exec(commandName string, args ...any) (reply any, err error) {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return nil, errors.New("missing required arguments")
|
return nil, errors.New("missing required arguments")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user