Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorCacheMiss = errors.New("cache miss error")
Functions ¶
This section is empty.
Types ¶
type CachedResponse ¶
CachedResponse 缓存的响应
type ICacheStore ¶
type ICacheStore interface { // Get 获取缓存,如果未获取到,返回 ErrorCacheMiss 错误 Get(key string, value *CachedResponse) error // Set 设置缓存,如果存在,则覆盖 Set(key string, value *CachedResponse, expire time.Duration) error // Delete 删除缓存,如果不存在,则不处理 Delete(key string) error }
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 *CachedResponse) error
Get retrieves an item from redis, if key doesn't exist, return ErrorCacheMiss
func (*RedisStore) Set ¶
func (store *RedisStore) Set(key string, value *CachedResponse, expire time.Duration) error
Set put key value pair to redis, and expire after expireDuration
Click to show internal directories.
Click to hide internal directories.