Import path:
gitlab.soludian.com/soludian/fountain/libs/cache/redis_cache
redis_cache
import "gitlab.soludian.com/soludian/fountain/libs/cache/redis_cache"Index
- Variables
- func NewRedisCache() cache.Cache
- type Cache
- func (rc *Cache) ClearAll(context.Context) error
- func (rc *Cache) Close() error
- func (rc *Cache) Decr(key string) (int64, error)
- func (rc *Cache) Delete(key string) error
- func (rc *Cache) Get(key string) ([]byte, error)
- func (rc *Cache) GetDefaultConfig() string
- func (rc *Cache) GetMulti(keys []string) ([][]byte, error)
- func (rc *Cache) Has(key string) bool
- func (rc *Cache) Incr(key string) (int64, error)
- func (rc *Cache) Peek(key string) (any, error)
- func (rc *Cache) PeekMulti(keys []string) ([]any, error)
- func (rc *Cache) Put(key string, val any, timeout time.Duration) error
- func (rc *Cache) PutMulti(values map[string]any, ttl time.Duration) error
- func (rc *Cache) Reset() error
- func (rc *Cache) Set(key string, val []byte, ttl time.Duration) error
- func (rc *Cache) SetMulti(values map[string][]byte, ttl time.Duration) error
- func (rc *Cache) SetName(name string)
- func (rc *Cache) StartAndGC(configs ...string) error
Variables
var (
KPackageName = "redis_cache"
// DefaultKey the collection name of redis for cache adapter.
DefaultKey = "fountain"
)var DefaultConfig = `{"addr": "127.0.0.1:6379"}`func NewRedisCache
func NewRedisCache() cache.CacheNewRedisCache create new redis cache with default collection name.
type Cache
Cache is Redis cache adapter.
type Cache struct {
// contains filtered or unexported fields
}func (*Cache) ClearAll
func (rc *Cache) ClearAll(context.Context) errorClearAll deletes all cache in the redis collection Be careful about this method, because it scans all keys and the delete them one by one
func (*Cache) Close
func (rc *Cache) Close() errorClose
func (*Cache) Decr
func (rc *Cache) Decr(key string) (int64, error)Decr decreases a key's counter in redis.
func (*Cache) Delete
func (rc *Cache) Delete(key string) errorDelete deletes a key's cache in redis.
func (*Cache) Get
func (rc *Cache) Get(key string) ([]byte, error)Get gets a key's value from memcache.
func (*Cache) GetDefaultConfig
func (rc *Cache) GetDefaultConfig() stringfunc (*Cache) GetMulti
func (rc *Cache) GetMulti(keys []string) ([][]byte, error)GetMulti gets one or keys values from ssdb.
func (*Cache) Has
func (rc *Cache) Has(key string) boolHas checks cache's existence in redis.
func (*Cache) Incr
func (rc *Cache) Incr(key string) (int64, error)Incr increases a key's counter in redis.
func (*Cache) Peek
func (rc *Cache) Peek(key string) (any, error)Peek cache from redis.
func (*Cache) PeekMulti
func (rc *Cache) PeekMulti(keys []string) ([]any, error)PeekMulti gets cache from redis.
func (*Cache) Put
func (rc *Cache) Put(key string, val any, timeout time.Duration) errorPut puts cache into redis.
func (*Cache) PutMulti
func (rc *Cache) PutMulti(values map[string]any, ttl time.Duration) errorfunc (*Cache) Reset
func (rc *Cache) Reset() errorfunc (*Cache) Set
func (rc *Cache) Set(key string, val []byte, ttl time.Duration) errorfunc (*Cache) SetMulti
func (rc *Cache) SetMulti(values map[string][]byte, ttl time.Duration) errorfunc (*Cache) SetName
func (rc *Cache) SetName(name string)func (*Cache) StartAndGC
func (rc *Cache) StartAndGC(configs ...string) errorStartAndGC start redis cache adapter. config is like {"name": "cache", "key":"collection key","addr":"127.0.0.1:6379","db_num":"0"} the cache item in redis are stored forever, so no gc operation.
Generated by gomarkdoc