Documentation ¶
Index ¶
- func Register(name string, adapter Store) error
- type MemoryStore
- func (s *MemoryStore) DeleteExpired()
- func (s *MemoryStore) Exist(key string) bool
- func (s *MemoryStore) Flush() 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) Put(key string, val interface{}, timeout time.Duration) error
- func (s *MemoryStore) SetPrefix(prefix string) *MemoryStore
- type RedisStore
- func (s *RedisStore) Exist(key string) bool
- func (s *RedisStore) Flush() 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) Put(key string, val interface{}, timeout time.Duration) error
- func (s *RedisStore) SetPool(pool *redis.Pool) *RedisStore
- func (s *RedisStore) SetPrefix(prefix string) *RedisStore
- type Repository
- func (r *Repository) Add(key string, val interface{}, timeout time.Duration) error
- func (r *Repository) Clear() error
- func (r *Repository) Delete(key string) 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) 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
- type Store
Constants ¶
This section is empty.
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) 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) 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) 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.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(pool *redis.Pool, prefix string) *RedisStore
NewStore Create a redis cache store
func (*RedisStore) Exist ¶
func (s *RedisStore) Exist(key string) bool
Exist check cache's existence in redis.
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) 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.
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) Delete ¶
func (r *Repository) Delete(key string) error
Delete Alias for the "Delete" method.
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) 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.
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 // Exist check cache's existence in redis. Exist(key string) bool // Forget Remove an item from the cache. Forget(key string) error // Flush Remove all items from the cache. Flush() error }