Documentation
¶
Index ¶
- Variables
- type Codec
- func (cd *Codec) Delete(key string) error
- func (cd *Codec) DeleteContext(ctx context.Context, key string) error
- func (cd *Codec) Exists(key string) bool
- func (cd *Codec) ExistsContext(ctx context.Context, key string) bool
- func (cd *Codec) Get(key string, object interface{}) error
- func (cd *Codec) GetContext(ctx context.Context, key string, object interface{}) error
- func (cd *Codec) Once(item *Item) error
- func (cd *Codec) Set(item *Item) error
- func (cd *Codec) Stats() *Stats
- func (cd *Codec) UseLocalCache(maxLen int, expiration time.Duration)
- type Item
- type RedisStore
- func (c *RedisStore) Add(key string, value interface{}, expires time.Duration) error
- func (c *RedisStore) Decrement(key string, delta uint64) (newValue uint64, err error)
- func (c *RedisStore) Delete(key string) error
- func (c *RedisStore) Flush() error
- func (c *RedisStore) Get(key string, ptrValue interface{}) error
- func (c *RedisStore) Increment(key string, delta uint64) (uint64, error)
- func (c *RedisStore) Replace(key string, value interface{}, expires time.Duration) error
- func (c *RedisStore) Set(key string, value interface{}, expires time.Duration) error
- type Stats
Constants ¶
This section is empty.
Variables ¶
var ErrCacheMiss = errors.New("cache: key is missing")
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct { Redis xservice.IRedis Marshal func(interface{}) ([]byte, error) Unmarshal func([]byte, interface{}) error // contains filtered or unexported fields }
func (*Codec) GetContext ¶
func (*Codec) Once ¶
Once gets the item.Object for the given item.Key from the cache or executes, caches, and returns the results of the given item.Func, making sure that only one execution is in-flight for a given item.Key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.
type Item ¶
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore represents the cache with redis persistence
func NewRedisCache ¶
func NewRedisCache(host string, password string, defaultExpiration time.Duration) *RedisStore
NewRedisCache returns a RedisStore until redigo supports sharding/clustering, only one host will be in hostList
func NewRedisCacheWithPool ¶
func NewRedisCacheWithPool(pool *redis.Pool, defaultExpiration time.Duration) *RedisStore
NewRedisCacheWithPool returns a RedisStore using the provided pool until redigo supports sharding/clustering, only one host will be in hostList
func (*RedisStore) Add ¶
func (c *RedisStore) Add(key string, value interface{}, expires time.Duration) error
Add (see CacheStore interface)
func (*RedisStore) Decrement ¶
func (c *RedisStore) Decrement(key string, delta uint64) (newValue uint64, err error)
Decrement (see CacheStore interface)
func (*RedisStore) Delete ¶
func (c *RedisStore) Delete(key string) error
Delete (see CacheStore interface)
func (*RedisStore) Get ¶
func (c *RedisStore) Get(key string, ptrValue interface{}) error
Get (see CacheStore interface)
func (*RedisStore) Increment ¶
func (c *RedisStore) Increment(key string, delta uint64) (uint64, error)
Increment (see CacheStore interface)