Documentation ¶
Index ¶
- Constants
- func Register(name string, adapter Store) error
- func Sha1(str string) string
- type MemoryStore
- func (s *MemoryStore) Decrement(key string, value ...int) (int, error)
- func (s *MemoryStore) DeleteExpired()
- func (s *MemoryStore) Exist(key string) bool
- func (s *MemoryStore) Expire(key string, timeout time.Duration) error
- func (s *MemoryStore) Flush() error
- func (s *MemoryStore) Forever(key string, val interface{}) error
- func (s *MemoryStore) Forget(key string) error
- func (s *MemoryStore) Get(key string, val interface{}) error
- func (s *MemoryStore) GetPrefix() string
- func (s *MemoryStore) Increment(key string, value ...int) (int, error)
- func (s *MemoryStore) Put(key string, val interface{}, timeout time.Duration) error
- func (s *MemoryStore) SetPrefix(prefix string) *MemoryStore
- func (s *MemoryStore) TTL(key string) (int64, error)
- func (s *MemoryStore) Tags(names ...string) Store
- type RedisStore
- func (s *RedisStore) Decrement(key string, value ...int) (int, error)
- func (s *RedisStore) Exist(key string) bool
- func (s *RedisStore) Expire(key string, timeout time.Duration) error
- func (s *RedisStore) Flush() error
- func (s *RedisStore) FlushByPrefix(prefix string) error
- func (s *RedisStore) Forever(key string, val interface{}) error
- func (s *RedisStore) Forget(key string) error
- func (s *RedisStore) Get(key string, val interface{}) error
- func (s *RedisStore) GetPrefix() string
- func (s *RedisStore) Increment(key string, value ...int) (int, error)
- func (s *RedisStore) Put(key string, val interface{}, timeout time.Duration) error
- func (s *RedisStore) SetPool(pool *redis.Pool) *RedisStore
- func (s *RedisStore) SetPrefix(prefix string) *RedisStore
- func (s *RedisStore) TTL(key string) (int64, error)
- func (s *RedisStore) Tags(names ...string) Store
- type Repository
- func (r *Repository) Add(key string, val interface{}, timeout time.Duration) error
- func (r *Repository) Clear() error
- func (r *Repository) Decrement(key string, value ...int) (int, error)
- func (r *Repository) Delete(key string) error
- func (r *Repository) Expire(key string, timeout time.Duration) error
- func (r *Repository) Forget(key string) error
- func (r *Repository) Get(key string, val interface{}) error
- func (r *Repository) GetStore() Store
- func (r *Repository) Has(key string) bool
- func (r *Repository) Increment(key string, value ...int) (int, error)
- func (r *Repository) Pull(key string, val interface{}) error
- func (r *Repository) Put(key string, val interface{}, timeout time.Duration) error
- func (r *Repository) Remember(key string, val interface{}, timeout time.Duration, ...) error
- func (r *Repository) Set(key string, val interface{}, timeout time.Duration) error
- func (r *Repository) TTL(key string) (int64, error)
- func (r *Repository) Tags(names ...string) *Repository
- type Store
- type TagSet
Constants ¶
const ReferenceKeyForever = "forever_ref"
ReferenceKeyForever Forever reference key.
const ReferenceKeyStandard = "standard_ref"
ReferenceKeyStandard Standard reference key.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore(prefix string) *MemoryStore
NewStore Create a memory cache store
func (*MemoryStore) Decrement ¶ added in v1.0.1
func (s *MemoryStore) Decrement(key string, value ...int) (int, error)
Decrement the value of an item in the cache.
func (*MemoryStore) DeleteExpired ¶
func (s *MemoryStore) DeleteExpired()
Delete all expired items from the cache.
func (*MemoryStore) Exist ¶
func (s *MemoryStore) Exist(key string) bool
Exist check cache's existence in memory.
func (*MemoryStore) Expire ¶ added in v1.0.1
func (s *MemoryStore) Expire(key string, timeout time.Duration) error
Expire set value expire time.
func (*MemoryStore) Forever ¶ added in v1.2.0
func (s *MemoryStore) Forever(key string, val interface{}) error
Forever Store an item in the cache indefinitely.
func (*MemoryStore) Forget ¶
func (s *MemoryStore) Forget(key string) error
Forget Remove an item from the cache.
func (*MemoryStore) Get ¶
func (s *MemoryStore) Get(key string, val interface{}) error
Get get cached value by key. func (s *Store) Get(key string) (interface{}, error) {
func (*MemoryStore) GetPrefix ¶
func (s *MemoryStore) GetPrefix() string
GetPrefix Get the cache key prefix.
func (*MemoryStore) Increment ¶ added in v1.0.1
func (s *MemoryStore) Increment(key string, value ...int) (int, error)
Increment the value of an item in the cache.
func (*MemoryStore) Put ¶
func (s *MemoryStore) Put(key string, val interface{}, timeout time.Duration) error
Put set cached value with key and expire time.
func (*MemoryStore) SetPrefix ¶
func (s *MemoryStore) SetPrefix(prefix string) *MemoryStore
SetPrefix Set the cache key prefix.
func (*MemoryStore) Tags ¶ added in v1.2.0
func (s *MemoryStore) Tags(names ...string) Store
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(pool *redis.Pool, prefix string) *RedisStore
NewRedisStore Create a redis cache store
func (*RedisStore) Decrement ¶ added in v1.0.1
func (s *RedisStore) Decrement(key string, value ...int) (int, error)
Decrement the value of an item in the cache.
func (*RedisStore) Exist ¶
func (s *RedisStore) Exist(key string) bool
Exist check cache's existence in redis.
func (*RedisStore) Expire ¶ added in v1.0.1
func (s *RedisStore) Expire(key string, timeout time.Duration) error
Expire set value expire time.
func (*RedisStore) FlushByPrefix ¶ added in v1.2.1
func (s *RedisStore) FlushByPrefix(prefix string) error
func (*RedisStore) Forever ¶ added in v1.2.0
func (s *RedisStore) Forever(key string, val interface{}) error
Forever Store an item in the cache indefinitely.
func (*RedisStore) Forget ¶
func (s *RedisStore) Forget(key string) error
Forget Remove an item from the cache.
func (*RedisStore) Get ¶
func (s *RedisStore) Get(key string, val interface{}) error
Get get cached value by key.
func (*RedisStore) GetPrefix ¶
func (s *RedisStore) GetPrefix() string
GetPrefix Get the cache key prefix.
func (*RedisStore) Increment ¶ added in v1.0.1
func (s *RedisStore) Increment(key string, value ...int) (int, error)
Increment the value of an item in the cache.
func (*RedisStore) Put ¶
func (s *RedisStore) Put(key string, val interface{}, timeout time.Duration) error
Put set cached value with key and expire time.
func (*RedisStore) SetPool ¶
func (s *RedisStore) SetPool(pool *redis.Pool) *RedisStore
SetPool Get the redis pool.
func (*RedisStore) SetPrefix ¶
func (s *RedisStore) SetPrefix(prefix string) *RedisStore
SetPrefix Set the cache key prefix.
func (*RedisStore) Tags ¶ added in v1.2.0
func (s *RedisStore) Tags(names ...string) Store
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func Cache ¶
func Cache(adapter interface{}) (*Repository, error)
NewCache Create a new cache by adapter name.
func NewRepository ¶
func NewRepository(store Store) *Repository
func (*Repository) Add ¶
func (r *Repository) Add(key string, val interface{}, timeout time.Duration) error
Add Store an item in the cache if the key does not exist.
func (*Repository) Clear ¶
func (r *Repository) Clear() error
Clear Remove all items from the cache.
func (*Repository) Decrement ¶ added in v1.0.1
func (r *Repository) Decrement(key string, value ...int) (int, error)
Decrement the value of an item in the cache.
func (*Repository) Delete ¶
func (r *Repository) Delete(key string) error
Delete Alias for the "Delete" method.
func (*Repository) Expire ¶ added in v1.0.1
func (r *Repository) Expire(key string, timeout time.Duration) error
Expire set value expire time.
func (*Repository) Forget ¶
func (r *Repository) Forget(key string) error
Forget Remove an item from the cache.
func (*Repository) Get ¶
func (r *Repository) Get(key string, val interface{}) error
Get Retrieve an item from the cache by key.
func (*Repository) GetStore ¶
func (r *Repository) GetStore() Store
GetStore Get the cache store implementation.
func (*Repository) Has ¶
func (r *Repository) Has(key string) bool
Has Determine if an item exists in the cache.
func (*Repository) Increment ¶ added in v1.0.1
func (r *Repository) Increment(key string, value ...int) (int, error)
Increment the value of an item in the cache.
func (*Repository) Pull ¶
func (r *Repository) Pull(key string, val interface{}) error
Pull Retrieve an item from the cache and delete it.
func (*Repository) Put ¶
func (r *Repository) Put(key string, val interface{}, timeout time.Duration) error
Put Store an item in the cache.
func (*Repository) Remember ¶
func (r *Repository) Remember(key string, val interface{}, timeout time.Duration, callback func() interface{}) error
Remember Get an item from the cache, or store the default value.
func (*Repository) Set ¶
func (r *Repository) Set(key string, val interface{}, timeout time.Duration) error
Set Store an item in the cache.
func (*Repository) TTL ¶ added in v1.0.1
func (r *Repository) TTL(key string) (int64, error)
TTL get the ttl of the key.
func (*Repository) Tags ¶ added in v1.2.0
func (r *Repository) Tags(names ...string) *Repository
Tags Begin executing a new tags operation if the store supports it.
type Store ¶
type Store interface { // Get get cached value by key. Get(key string, val interface{}) error // Put set cached value with key and expire time. Put(key string, val interface{}, timeout time.Duration) error // Increment the value of an item in the cache. Increment(key string, value ...int) (int, error) // Decrement the value of an item in the cache. Decrement(key string, value ...int) (int, error) // Forever Store an item in the cache indefinitely. Forever(key string, val interface{}) error // Exist check cache's existence in redis. Exist(key string) bool // Expire set value expire time. Expire(key string, timeout time.Duration) error // Forget Remove an item from the cache. Forget(key string) error // Flush Remove all items from the cache. Flush() error Tags(names ...string) Store // TTL get the ttl of the key. TTL(key string) (int64, error) }
type TagSet ¶ added in v1.2.0
type TagSet struct {
// contains filtered or unexported fields
}