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) Flush() error
- func (self *CacheManager) Get(key string, input interface{}) (interface{}, bool, error)
- func (self *CacheManager) GetBool(key string) (bool, 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{}) 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) Flush() error
- func (self *LocalMapManager) Get(key string, input interface{}) (interface{}, bool, error)
- func (self *LocalMapManager) GetBool(key string) (bool, 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)
- 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) Flush() error
- func (self *RedisManager) Get(key string, input interface{}) (interface{}, bool, error)
- func (self *RedisManager) GetBool(key string) (bool, 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{}) 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) 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) // 查询队列数据 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{}) 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 }
缓存定义接口接口
func NewLocalCache ¶
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) Flush ¶
func (self *CacheManager) Flush() error
func (*CacheManager) Get ¶
func (self *CacheManager) Get(key string, input interface{}) (interface{}, bool, 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{}) 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) Flush ¶
func (self *LocalMapManager) Flush() error
func (*LocalMapManager) Get ¶
func (self *LocalMapManager) Get(key string, input interface{}) (interface{}, bool, 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默认校验数据间隔时间/分钟
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) Flush ¶
func (self *RedisManager) Flush() error
func (*RedisManager) Get ¶
func (self *RedisManager) Get(key string, input interface{}) (interface{}, bool, 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{}) 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.