Documentation ¶
Index ¶
- Variables
- func New(opts ...CacheOptions) cache.Cache
- type Cache
- func (c *Cache) Clear() error
- func (c *Cache) Decrement(key string, step int) error
- func (c *Cache) Delete(key string) error
- func (c *Cache) Get(key string) (any, error)
- func (c *Cache) GetMulti(keys []string) ([]any, error)
- func (c *Cache) Has(key string) (bool, error)
- func (c *Cache) Increment(key string, step int) error
- func (c *Cache) Name() string
- func (c *Cache) Scan(pattern string) (keys []string, err error)
- func (c *Cache) Set(key string, value any, ttl time.Duration) error
- type CacheOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultKey = "gocache"
DefaultKey defines the collection name of redis for the cache adapter.
Functions ¶
func New ¶
func New(opts ...CacheOptions) cache.Cache
New creates a new redis cache with default collection name.
Types ¶
type Cache ¶
type Cache struct { Redis *redis.Pool // redis connection pool Key string CacheItem cache.ICacheItem }
func (*Cache) Clear ¶
Clear deletes all cache in the redis collection Be careful about this method, because it scans all keys and the delete them one by one
type CacheOptions ¶
type CacheOptions func(c *Cache)
func CacheWithCacheItem ¶
func CacheWithCacheItem(cacheItem cache.ICacheItem) CacheOptions
func CacheWithKey ¶
func CacheWithKey(key string) CacheOptions
CacheWithKey configures key for redis
func CacheWithRedisPool ¶
func CacheWithRedisPool(pool *redis.Pool) CacheOptions
CacheWithRedisPool configures prefix for redis
Click to show internal directories.
Click to hide internal directories.