Documentation ¶
Overview ¶
Package cache is redis cache libraries.
Index ¶
- Variables
- func BuildCacheKey(keyPrefix string, key string) (string, error)
- func Del(ctx context.Context, keys ...string) error
- func Get(ctx context.Context, key string, val interface{}) error
- func GetLock(ctx context.Context, key string, options ...redsync.Option) error
- func GetLoopLock(ctx context.Context, key string, options ...redsync.Option) error
- func MultiGet(ctx context.Context, keys []string, valueMap interface{}) error
- func MultiSet(ctx context.Context, valMap map[string]interface{}, expireTime time.Duration) error
- func ReleaseLock(ctx context.Context) error
- func Set(ctx context.Context, key string, val interface{}, expireTime time.Duration) error
- func SetCacheWithNotFound(ctx context.Context, key string) error
- type Cache
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultExpireTime default expiry time DefaultExpireTime = time.Hour * 24 // DefaultNotFoundExpireTime expiry time when result is empty 1 minute, // often used for cache time when data is empty (cache pass-through) DefaultNotFoundExpireTime = time.Minute * 1 // NotFoundPlaceholder placeholder NotFoundPlaceholder = "*" // DefaultClient generate a cache client, where keyPrefix is generally the business prefix DefaultClient Cache // ErrPlaceholder . ErrPlaceholder = errors.New("cache: placeholder") )
View Source
var CacheNotFound = redis.Nil
CacheNotFound no hit cache
Functions ¶
func BuildCacheKey ¶
BuildCacheKey construct a cache key with a prefix
func GetLoopLock ¶ added in v1.1.6
func ReleaseLock ¶ added in v1.1.4
Types ¶
type Cache ¶
type Cache interface { GetLoopLock(ctx context.Context, key string, options ...redsync.Option) error GetLock(ctx context.Context, key string, options ...redsync.Option) error ReleaseLock(ctx context.Context) error Set(ctx context.Context, key string, val interface{}, expireTime time.Duration) error Get(ctx context.Context, key string, val interface{}) error MultiSet(ctx context.Context, valMap map[string]interface{}, expireTime time.Duration) error MultiGet(ctx context.Context, keys []string, valueMap interface{}) error Del(ctx context.Context, keys ...string) error SetCacheWithNotFound(ctx context.Context, key string) error }
Cache driver interface
Click to show internal directories.
Click to hide internal directories.