Documentation ¶
Index ¶
- Constants
- Variables
- func MemCacheConfig() map[string]interface{}
- func MemoryInConfig() map[string]interface{}
- type Cache
- type CacheConfig
- type CacheError
- type MemCache
- type MemoryInCache
- type RedisCache
- func (rc *RedisCache) Add(key string, value interface{}, expire time.Duration) error
- func (rc *RedisCache) Conn() redis.Conn
- func (rc *RedisCache) Delete(key string) error
- func (rc *RedisCache) Flush() error
- func (rc *RedisCache) Get(key string, value interface{}) error
- func (rc *RedisCache) Incr(key string, delta int64) (int64, error)
- func (rc *RedisCache) Replace(key string, value interface{}, expire time.Duration) error
- func (rc *RedisCache) Set(key string, value interface{}, expire time.Duration) error
- type RedisConfig
Constants ¶
View Source
const ( MemoryInT cacheType = "memory" RedisT cacheType = "redis" MemCacheT cacheType = "memcache" )
View Source
const ( DEFAULT = time.Duration(0) FOREVER = time.Duration(-1) )
Variables ¶
View Source
var ( UnKnownCacheError = NewCacheError(11001, "unknown cache error") UnsupportedCacheTypeError = NewCacheError(11002, "unsupported cache type,supported cache type:) "+strings.Join(supportedCacheType, ",")) AutoInitCacheError = NewCacheError(11003, "auto init cache error") NoKeyCacheError = NewCacheError(11004, "no key cache error") )
Functions ¶
func MemCacheConfig ¶
func MemCacheConfig() map[string]interface{}
func MemoryInConfig ¶
func MemoryInConfig() map[string]interface{}
Types ¶
type Cache ¶
type Cache interface { Get(key string, value interface{}) error Set(key string, value interface{}, expire time.Duration) error Add(key string, value interface{}, expire time.Duration) error Replace(key string, data interface{}, expire time.Duration) error Delete(key string) error Incr(key string, data int64) (int64, error) Flush() error }
func NewAutoCache ¶
func NewAutoCache(cc CacheConfig) (Cache, error)
auto select cache type: Redis,MemCache,MemoryIn
func NewCache ¶
func NewCache(c cacheType, cc CacheConfig) (Cache, error)
supported cache type: Redis,MemCache,MemoryIn
type CacheConfig ¶
type CacheConfig func() map[string]interface{}
type CacheError ¶
type CacheError struct {
// contains filtered or unexported fields
}
func NewCacheError ¶
func NewCacheError(code int, ds ...string) CacheError
func (CacheError) Error ¶
func (c CacheError) Error() string
func (CacheError) WithDetails ¶
func (c CacheError) WithDetails(ds ...string) CacheError
type MemCache ¶
type MemCache struct {
Cache
}
func NewMemCache ¶
func NewMemCache(cc CacheConfig) (*MemCache, error)
type MemoryInCache ¶
type MemoryInCache struct {
Cache
}
func NewMemoryInCache ¶
func NewMemoryInCache(cc CacheConfig) (*MemoryInCache, error)
type RedisCache ¶
type RedisCache struct { Cache // contains filtered or unexported fields }
func NewRedisCache ¶
func NewRedisCache(cc CacheConfig) (*RedisCache, error)
func (*RedisCache) Add ¶
func (rc *RedisCache) Add(key string, value interface{}, expire time.Duration) error
func (*RedisCache) Conn ¶
func (rc *RedisCache) Conn() redis.Conn
func (*RedisCache) Delete ¶
func (rc *RedisCache) Delete(key string) error
func (*RedisCache) Flush ¶
func (rc *RedisCache) Flush() error
func (*RedisCache) Get ¶
func (rc *RedisCache) Get(key string, value interface{}) error
type RedisConfig ¶
type RedisConfig struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.