Documentation ¶
Index ¶
- func NewRedisCache(client redis.Cmdable, opts ...CacheOptions) cache.Cache
- type Cache
- func (rc *Cache) ClearAll(ctx context.Context) error
- func (rc *Cache) Decr(ctx context.Context, key string) error
- func (rc *Cache) Delete(ctx context.Context, key string) error
- func (rc *Cache) Get(ctx context.Context, key string) (interface{}, error)
- func (rc *Cache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error)
- func (rc *Cache) Incr(ctx context.Context, key string) error
- func (rc *Cache) IsExist(ctx context.Context, key string) (bool, error)
- func (rc *Cache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error
- func (rc *Cache) Scan(ctx context.Context, pattern string) ([]string, error)
- type CacheOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedisCache ¶
func NewRedisCache(client redis.Cmdable, opts ...CacheOptions) cache.Cache
NewRedisCache creates a new redis cache with default collection name.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is Redis cache adapter.
func (*Cache) ClearAll ¶
ClearAll deletes all cache in the redis collection Be careful about this method, because it scans all keys and the delete them one by one if you add more prefix-value during calling ClearAll function, those new prefix-value pairs will not be deleted.
type CacheOptions ¶
type CacheOptions func(c *Cache)
func CacheWithPrefix ¶
func CacheWithPrefix(key string) CacheOptions
CacheWithPrefix configures prefix for redis prefix should not be empty string
func CacheWithScanCount ¶
func CacheWithScanCount(count int64) CacheOptions
CacheWithScanCount configures scan count for redis
Click to show internal directories.
Click to hide internal directories.