Documentation
¶
Overview ¶
Package cache provides the cache management interface define
Package cache implements a distributed cache Interface redis_remote_cache.go implements a distributed cache with redis
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache: key is missing")
ErrCacheMiss cache miss error if Get() method return this error, means key is not exist
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { // Set the key value to cache Set(ctx context.Context, k string, v []byte, ttl time.Duration) error // Get the key value from cache Get(ctx context.Context, k string) ([]byte, error) // Del delete the key from cache Del(ctx context.Context, k string) error // Close the cache Close() error }
Interface cache interface
func NewLocalCache ¶
func NewLocalCache(c *configs.LocalCacheConfig) (Interface, error)
NewLocalCache create a local cache capacity is the cache capacity ttl is the time to live
func NewProxy ¶
func NewProxy(c *configs.CacheConfig) (Interface, error)
NewProxy creates a new cache proxy, which contains a distributed cache and a local cache
func NewRedisRemoteCache ¶
func NewRedisRemoteCache(c *configs.RedisConfig) Interface
NewRedisRemoteCache returns a new redis cache
Click to show internal directories.
Click to hide internal directories.