Documentation ¶
Index ¶
- func SpinLocker(lockObj, errorMsg string, trySecond, expSecond int, callObj func() error) error
- func TryLocker(lockObj, errorMsg string, expSecond int, callObj func() error) error
- type Cache
- type CacheManager
- func (self *CacheManager) Brpop(key string, expire int64, result interface{}) error
- func (self *CacheManager) BrpopBool(key string, expire int64) (bool, error)
- func (self *CacheManager) BrpopFloat64(key string, expire int64) (float64, error)
- func (self *CacheManager) BrpopInt64(key string, expire int64) (int64, error)
- func (self *CacheManager) BrpopString(key string, expire int64) (string, error)
- func (self *CacheManager) Del(key ...string) error
- func (self *CacheManager) Exists(key string) (bool, error)
- func (self *CacheManager) Flush() error
- func (self *CacheManager) Get(key string, input interface{}) (interface{}, bool, error)
- func (self *CacheManager) GetBool(key string) (bool, error)
- func (self *CacheManager) GetBytes(key string) ([]byte, error)
- func (self *CacheManager) GetFloat64(key string) (float64, error)
- func (self *CacheManager) GetInt64(key string) (int64, error)
- func (self *CacheManager) GetString(key string) (string, error)
- func (self *CacheManager) Keys(pattern ...string) ([]string, error)
- func (self *CacheManager) LuaScript(script string, key []string, val ...interface{}) (interface{}, error)
- func (self *CacheManager) Publish(key string, val interface{}, try ...int) (bool, error)
- func (self *CacheManager) Put(key string, input interface{}, expire ...int) error
- func (self *CacheManager) PutBatch(objs ...*PutObj) error
- func (self *CacheManager) Rpush(key string, val interface{}) error
- func (self *CacheManager) Size(pattern ...string) (int, error)
- func (self *CacheManager) Subscribe(key string, timeout int, call func(msg string) (bool, error)) error
- func (self *CacheManager) Values(pattern ...string) ([]interface{}, error)
- type LocalMapManager
- func (self *LocalMapManager) Del(key ...string) error
- func (self *LocalMapManager) Exists(key string) (bool, error)
- func (self *LocalMapManager) Flush() error
- func (self *LocalMapManager) Get(key string, input interface{}) (interface{}, bool, error)
- func (self *LocalMapManager) GetBool(key string) (bool, error)
- func (self *LocalMapManager) GetBytes(key string) ([]byte, error)
- func (self *LocalMapManager) GetFloat64(key string) (float64, error)
- func (self *LocalMapManager) GetInt64(key string) (int64, error)
- func (self *LocalMapManager) GetString(key string) (string, error)
- func (self *LocalMapManager) NewCache(a, b int) Cache
- func (self *LocalMapManager) Put(key string, input interface{}, expire ...int) error
- func (self *LocalMapManager) Size(pattern ...string) (int, error)
- func (self *LocalMapManager) Values(pattern ...string) ([]interface{}, error)
- type Lock
- type PutObj
- type RedisConfig
- type RedisManager
- func (self *RedisManager) Brpop(key string, expire int64, result interface{}) error
- func (self *RedisManager) BrpopBool(key string, expire int64) (bool, error)
- func (self *RedisManager) BrpopFloat64(key string, expire int64) (float64, error)
- func (self *RedisManager) BrpopInt64(key string, expire int64) (int64, error)
- func (self *RedisManager) BrpopString(key string, expire int64) (string, error)
- func (self *RedisManager) Client(ds ...string) (*RedisManager, error)
- func (self *RedisManager) Close(conn redis.Conn)
- func (self *RedisManager) Del(key ...string) error
- func (self *RedisManager) Exists(key string) (bool, error)
- func (self *RedisManager) Flush() error
- func (self *RedisManager) Get(key string, input interface{}) (interface{}, bool, error)
- func (self *RedisManager) GetBool(key string) (bool, error)
- func (self *RedisManager) GetBytes(key string) ([]byte, error)
- func (self *RedisManager) GetFloat64(key string) (float64, error)
- func (self *RedisManager) GetInt64(key string) (int64, error)
- func (self *RedisManager) GetString(key string) (string, error)
- func (self *RedisManager) InitConfig(input ...RedisConfig) (*RedisManager, error)
- func (self *RedisManager) Keys(pattern ...string) ([]string, error)
- func (self *RedisManager) LuaScript(cmd string, key []string, val ...interface{}) (interface{}, error)
- func (self *RedisManager) Publish(key string, val interface{}, try ...int) (bool, error)
- func (self *RedisManager) Put(key string, input interface{}, expire ...int) error
- func (self *RedisManager) PutBatch(objs ...*PutObj) error
- func (self *RedisManager) Rpush(key string, val interface{}) error
- func (self *RedisManager) Size(pattern ...string) (int, error)
- func (self *RedisManager) SpinLockWithTimeout(resource string, trySecond, expSecond int, call func() error) error
- func (self *RedisManager) Subscribe(key string, expSecond int, call func(msg string) (bool, error)) error
- func (self *RedisManager) TryLockWithTimeout(resource string, expSecond int, call func() error) error
- func (self *RedisManager) Values(pattern ...string) ([]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SpinLocker ¶
Types ¶
type Cache ¶
type Cache interface { // 查询 Get(key string, input interface{}) (interface{}, bool, error) GetInt64(key string) (int64, error) GetFloat64(key string) (float64, error) GetString(key string) (string, error) GetBytes(key string) ([]byte, error) GetBool(key string) (bool, error) // 保存/过期时间(秒) Put(key string, input interface{}, expire ...int) error // 批量保存/过期时间(秒) PutBatch(objs ...*PutObj) error // 删除 Del(input ...string) error // 查询全部key数量 Size(pattern ...string) (int, error) // 查询全部key Keys(pattern ...string) ([]string, error) // 查询全部key Values(pattern ...string) ([]interface{}, error) // 查询key是否存在 Exists(key string) (bool, error) // 查询队列数据 Brpop(key string, expire int64, result interface{}) error BrpopString(key string, expire int64) (string, error) BrpopInt64(key string, expire int64) (int64, error) BrpopFloat64(key string, expire int64) (float64, error) BrpopBool(key string, expire int64) (bool, error) // 发送队列数据 Rpush(key string, val interface{}) error // 发送订阅数据 Publish(key string, val interface{}, try ...int) (bool, error) // 监听订阅数据 Subscribe(key string, timeout int, call func(msg string) (bool, error)) error // 发送lua脚本 LuaScript(script string, key []string, val ...interface{}) (interface{}, error) // 清空全部key-value Flush() error }
缓存定义接口接口
type CacheManager ¶
type CacheManager struct{}
缓存管理器
func (*CacheManager) Brpop ¶
func (self *CacheManager) Brpop(key string, expire int64, result interface{}) error
func (*CacheManager) BrpopBool ¶
func (self *CacheManager) BrpopBool(key string, expire int64) (bool, error)
func (*CacheManager) BrpopFloat64 ¶
func (self *CacheManager) BrpopFloat64(key string, expire int64) (float64, error)
func (*CacheManager) BrpopInt64 ¶
func (self *CacheManager) BrpopInt64(key string, expire int64) (int64, error)
func (*CacheManager) BrpopString ¶
func (self *CacheManager) BrpopString(key string, expire int64) (string, error)
func (*CacheManager) Del ¶
func (self *CacheManager) Del(key ...string) error
func (*CacheManager) Exists ¶ added in v1.0.92
func (self *CacheManager) Exists(key string) (bool, error)
func (*CacheManager) Flush ¶
func (self *CacheManager) Flush() error
func (*CacheManager) Get ¶
func (self *CacheManager) Get(key string, input interface{}) (interface{}, bool, error)
func (*CacheManager) GetBytes ¶ added in v1.0.154
func (self *CacheManager) GetBytes(key string) ([]byte, error)
func (*CacheManager) GetFloat64 ¶
func (self *CacheManager) GetFloat64(key string) (float64, error)
func (*CacheManager) LuaScript ¶
func (self *CacheManager) LuaScript(script string, key []string, val ...interface{}) (interface{}, error)
func (*CacheManager) Publish ¶
func (self *CacheManager) Publish(key string, val interface{}, try ...int) (bool, error)
func (*CacheManager) Put ¶
func (self *CacheManager) Put(key string, input interface{}, expire ...int) error
func (*CacheManager) PutBatch ¶
func (self *CacheManager) PutBatch(objs ...*PutObj) error
func (*CacheManager) Rpush ¶
func (self *CacheManager) Rpush(key string, val interface{}) error
func (*CacheManager) Subscribe ¶
func (self *CacheManager) Subscribe(key string, timeout int, call func(msg string) (bool, error)) error
exp second
func (*CacheManager) Values ¶
func (self *CacheManager) Values(pattern ...string) ([]interface{}, error)
type LocalMapManager ¶
type LocalMapManager struct { CacheManager // contains filtered or unexported fields }
本地缓存管理器
func (*LocalMapManager) Del ¶
func (self *LocalMapManager) Del(key ...string) error
func (*LocalMapManager) Exists ¶ added in v1.0.92
func (self *LocalMapManager) Exists(key string) (bool, error)
func (*LocalMapManager) Flush ¶
func (self *LocalMapManager) Flush() error
func (*LocalMapManager) Get ¶
func (self *LocalMapManager) Get(key string, input interface{}) (interface{}, bool, error)
func (*LocalMapManager) GetBytes ¶ added in v1.0.154
func (self *LocalMapManager) GetBytes(key string) ([]byte, error)
func (*LocalMapManager) GetFloat64 ¶
func (self *LocalMapManager) GetFloat64(key string) (float64, error)
func (*LocalMapManager) GetString ¶
func (self *LocalMapManager) GetString(key string) (string, error)
func (*LocalMapManager) NewCache ¶
func (self *LocalMapManager) NewCache(a, b int) Cache
a默认缓存时间/分钟 b默认校验数据间隔时间/分钟
func (*LocalMapManager) Put ¶
func (self *LocalMapManager) Put(key string, input interface{}, expire ...int) error
func (*LocalMapManager) Size ¶
func (self *LocalMapManager) Size(pattern ...string) (int, error)
数据量大时请慎用
func (*LocalMapManager) Values ¶ added in v1.0.152
func (self *LocalMapManager) Values(pattern ...string) ([]interface{}, error)
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents a held lock.
type RedisConfig ¶
type RedisManager ¶
type RedisManager struct { CacheManager DsName string Pool *redis.Pool }
func NewRedis ¶
func NewRedis(ds ...string) (*RedisManager, error)
func (*RedisManager) Brpop ¶
func (self *RedisManager) Brpop(key string, expire int64, result interface{}) error
func (*RedisManager) BrpopBool ¶
func (self *RedisManager) BrpopBool(key string, expire int64) (bool, error)
func (*RedisManager) BrpopFloat64 ¶
func (self *RedisManager) BrpopFloat64(key string, expire int64) (float64, error)
func (*RedisManager) BrpopInt64 ¶
func (self *RedisManager) BrpopInt64(key string, expire int64) (int64, error)
func (*RedisManager) BrpopString ¶
func (self *RedisManager) BrpopString(key string, expire int64) (string, error)
func (*RedisManager) Client ¶
func (self *RedisManager) Client(ds ...string) (*RedisManager, error)
func (*RedisManager) Close ¶
func (self *RedisManager) Close(conn redis.Conn)
func (*RedisManager) Del ¶
func (self *RedisManager) Del(key ...string) error
func (*RedisManager) Exists ¶ added in v1.0.92
func (self *RedisManager) Exists(key string) (bool, error)
func (*RedisManager) Flush ¶
func (self *RedisManager) Flush() error
func (*RedisManager) Get ¶
func (self *RedisManager) Get(key string, input interface{}) (interface{}, bool, error)
func (*RedisManager) GetBytes ¶ added in v1.0.154
func (self *RedisManager) GetBytes(key string) ([]byte, error)
func (*RedisManager) GetFloat64 ¶
func (self *RedisManager) GetFloat64(key string) (float64, error)
func (*RedisManager) InitConfig ¶
func (self *RedisManager) InitConfig(input ...RedisConfig) (*RedisManager, error)
func (*RedisManager) LuaScript ¶
func (self *RedisManager) LuaScript(cmd string, key []string, val ...interface{}) (interface{}, error)
func (*RedisManager) Publish ¶
func (self *RedisManager) Publish(key string, val interface{}, try ...int) (bool, error)
func (*RedisManager) Put ¶
func (self *RedisManager) Put(key string, input interface{}, expire ...int) error
func (*RedisManager) PutBatch ¶
func (self *RedisManager) PutBatch(objs ...*PutObj) error
func (*RedisManager) Rpush ¶
func (self *RedisManager) Rpush(key string, val interface{}) error
func (*RedisManager) SpinLockWithTimeout ¶
func (self *RedisManager) SpinLockWithTimeout(resource string, trySecond, expSecond int, call func() error) error
func (*RedisManager) TryLockWithTimeout ¶
func (self *RedisManager) TryLockWithTimeout(resource string, expSecond int, call func() error) error
func (*RedisManager) Values ¶
func (self *RedisManager) Values(pattern ...string) ([]interface{}, error)
Click to show internal directories.
Click to hide internal directories.