Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("persist cache miss error")
ErrCacheMiss represent the cache key does not exist in the store
Functions ¶
func Deserialize ¶
Deserialize will deserialize the passed []byte into the passed ptr interface{}
Types ¶
type CacheStore ¶
type CacheStore interface { // Get retrieves an item from the Cache. if key does not exist in the store, return ErrCacheMiss Get(key string, value interface{}) error // Set sets an item to the Cache, replacing any existing item. Set(key string, value interface{}, expire time.Duration) error // Delete removes an item from the Cache. Does nothing if the key is not in the Cache. Delete(key string) error }
CacheStore is the interface of a Cache backend
type MemoryStore ¶
type MemoryStore struct {
Cache *ttlcache.Cache
}
MemoryStore local memory cache store
func NewMemoryStore ¶
func NewMemoryStore(defaultExpiration time.Duration) *MemoryStore
NewMemoryStore allocate a local memory store with default expiration
func (*MemoryStore) Delete ¶
func (c *MemoryStore) Delete(key string) error
Delete remove key in memory store, do nothing if key doesn't exist
func (*MemoryStore) Get ¶
func (c *MemoryStore) Get(key string, value interface{}) error
Get key in memory store, if key doesn't exist, return ErrCacheMiss
type RedisStore ¶
type RedisStore struct {
RedisClient *redis.Client
}
RedisStore store http response in redis
func NewRedisStore ¶
func NewRedisStore(redisClient *redis.Client) *RedisStore
NewRedisStore create a redis memory store with redis client
func (*RedisStore) Delete ¶
func (store *RedisStore) Delete(key string) error
Delete remove key in redis, do nothing if key doesn't exist
func (*RedisStore) Get ¶
func (store *RedisStore) Get(key string, value interface{}) error
Get retrieves an item from redis, if key doesn't exist, return ErrCacheMiss
Click to show internal directories.
Click to hide internal directories.