Documentation ¶
Index ¶
- Constants
- func Register(name string, store Store)
- func Version() string
- type AdapterConfig
- type Cache
- func (this *Cache) Connect(opt Options) error
- func (this *Cache) Decr(key string) int64
- func (this *Cache) Delete(key string)
- func (this *Cache) DeleteByPrefix(prefix string)
- func (this *Cache) Flush()
- func (this *Cache) Get(key string) string
- func (this *Cache) Incr(key string) int64
- func (this *Cache) IsExist(key string) bool
- func (this *Cache) Set(key, val string, expiration time.Duration)
- func (this *Cache) Touch(key string)
- type MemoryCache
- func (r *MemoryCache) Client() interface{}
- func (c *MemoryCache) Connect(opt Options) error
- func (c *MemoryCache) Decr(key string) int64
- func (c *MemoryCache) Delete(key string)
- func (c *MemoryCache) DeleteByPrefix(prefix string)
- func (c *MemoryCache) Flush()
- func (c *MemoryCache) Forever(key, val string) error
- func (c *MemoryCache) Get(key string) string
- func (c *MemoryCache) Incr(key string) int64
- func (c *MemoryCache) IsExist(key string) bool
- func (c *MemoryCache) Set(key, val string, expiration time.Duration)
- func (c *MemoryCache) Touch(key string)
- type MemoryItem
- type Options
- type RedisCache
- func (r *RedisCache) Client() interface{}
- func (r *RedisCache) Connect(opt Options) error
- func (r *RedisCache) Decr(key string) int64
- func (r *RedisCache) Delete(key string)
- func (r *RedisCache) DeleteByPrefix(prefix string)
- func (r *RedisCache) Flush()
- func (r *RedisCache) Get(key string) string
- func (r *RedisCache) Incr(key string) int64
- func (r *RedisCache) IsExist(key string) bool
- func (r *RedisCache) Set(key, val string, expiration time.Duration)
- func (r *RedisCache) Touch(key string)
- type Store
Constants ¶
const VersionName = "0.1.0"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdapterConfig ¶
type Cache ¶
type Cache struct { Opt Options // contains filtered or unexported fields }
func (*Cache) DeleteByPrefix ¶
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache represents a memory cache adapter implementation.
func NewMemoryCache ¶
func NewMemoryCache() *MemoryCache
NewMemoryCache creates and returns a new memory cache.
func (*MemoryCache) Client ¶ added in v0.5.0
func (r *MemoryCache) Client() interface{}
func (*MemoryCache) Connect ¶
func (c *MemoryCache) Connect(opt Options) error
func (*MemoryCache) Decr ¶
func (c *MemoryCache) Decr(key string) int64
Decr decreases cached int-type value by given key as a counter.
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(key string)
Delete deletes cached value by given key.
func (*MemoryCache) DeleteByPrefix ¶
func (c *MemoryCache) DeleteByPrefix(prefix string)
Delete deletes cached value by given prefix.
func (*MemoryCache) Forever ¶
func (c *MemoryCache) Forever(key, val string) error
put value into cache with key forever save
func (*MemoryCache) Get ¶
func (c *MemoryCache) Get(key string) string
Get gets cached value by given key.
func (*MemoryCache) Incr ¶
func (c *MemoryCache) Incr(key string) int64
Incr increases cached int-type value by given key as a counter.
func (*MemoryCache) IsExist ¶
func (c *MemoryCache) IsExist(key string) bool
IsExist returns true if cached value exists.
type MemoryItem ¶
type MemoryItem struct {
// contains filtered or unexported fields
}
MemoryItem represents a memory cache item.
type Options ¶
type Options struct { // Name of adapter. Default is "redis". Adapter string // Adapter configuration, it's corresponding to adapter. AdapterConfig AdapterConfig // key prefix Default is "" Section string }
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func NewRedisCache ¶
func NewRedisCache() *RedisCache
NewRedisCache creates and returns a new redis cache.
func (*RedisCache) Client ¶ added in v0.5.0
func (r *RedisCache) Client() interface{}
func (*RedisCache) Connect ¶
func (r *RedisCache) Connect(opt Options) error
func (*RedisCache) Decr ¶
func (r *RedisCache) Decr(key string) int64
Decr decreases cached int-type value by given key as a counter.
func (*RedisCache) Delete ¶
func (r *RedisCache) Delete(key string)
Delete deletes cached value by given key.
func (*RedisCache) DeleteByPrefix ¶
func (r *RedisCache) DeleteByPrefix(prefix string)
Delete deletes cached value by given prefix key.
func (*RedisCache) Get ¶
func (r *RedisCache) Get(key string) string
func (*RedisCache) Incr ¶
func (r *RedisCache) Incr(key string) int64
Incr increases cached int-type value by given key as a counter.
func (*RedisCache) IsExist ¶
func (r *RedisCache) IsExist(key string) bool
IsExist returns true if cached value exists.
type Store ¶
type Store interface { // Connect based on config string settings. Connect(opt Options) error // Client get client Client() interface{} // Set puts value into cache with key and expire time. Set(key, val string, expiration time.Duration) // Get gets cached value by given key. Get(key string) string // Delete deletes cached value by given key. Delete(key string) // DeleteByPrefix deletes cached value by given prefix. DeleteByPrefix(prefix string) // Incr increases cached int-type value by given key as a counter. Incr(key string) int64 // Decr decreases cached int-type value by given key as a counter. Decr(key string) int64 // IsExist returns true if cached value exists. IsExist(key string) bool // Touch touch Touch(key string) // Flush deletes all cached data. Flush() }
Store Cache is the interface that operates the cache data.