Documentation ¶
Index ¶
- Variables
- type RedisEntry
- func (re RedisEntry) Del(key string) error
- func (re RedisEntry) Expire(key string, second time.Duration) (int64, error)
- func (re RedisEntry) GetBit(key string, offset uint64) (int64, error)
- func (re RedisEntry) HMGet(keys ...interface{}) (map[string]string, error)
- func (re RedisEntry) HMSet(kvs ...interface{}) error
- func (re RedisEntry) IncrBy(key string, increment int64) (int64, error)
- func (re RedisEntry) ObtainLock(key, val string, ttl time.Duration) (int64, error)
- func (re RedisEntry) PExpire(key string, millisecond time.Duration) (int64, error)
- func (re RedisEntry) PTTL(key string) (int64, error)
- func (re RedisEntry) ReleaseLock(key, val, publishKey, publishMsg string) (int, error)
- func (re RedisEntry) RenewLock(key, val string, ttl time.Duration) (int, error)
- func (re RedisEntry) SetBit(key string, offset uint64, value int) error
- func (re RedisEntry) SubscribeAndReceiveMessage(publishKey string, timeout time.Duration) (msg string, err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ObtainLockScript = redis.NewScript(2, ` if (redis.call('exists', KEYS[1]) == 0) or (redis.call('hexists',KEYS[1],KEYS[2]) == 1) then redis.call('hincrby', KEYS[1], KEYS[2],1); redis.call('pexpire', KEYS[1], ARGV[1]); return 0; end; return redis.call('pttl', KEYS[1]); `) ReleaseLockScript = redis.NewScript(3, ` if redis.call('hexists',KEYS[1],KEYS[2]) == 1 then local count = redis.call('hincrby', KEYS[1], KEYS[2], -1); if (count <= 0) then redis.call('del', KEYS[1]); redis.call('publish', KEYS[3], ARGV[1]); end; return 1; end; if redis.call('exists', KEYS[1]) == 0 then return 0; else return -1; end; `) RenewExpLocktScript = redis.NewScript(2, ` if (redis.call('hexists', KEYS[1], KEYS[2]) == 1) then redis.call('pexpire', KEYS[1], ARGV[1]); return 1; end; if redis.call('exists', KEYS[1]) == 0 then return 0; else return -1; end; `) )
Functions ¶
This section is empty.
Types ¶
type RedisEntry ¶
type RedisEntry struct {
// contains filtered or unexported fields
}
func NewRedisEntry ¶
func NewRedisEntry(redisAddr, redisPass string) RedisEntry
func NewRedisEntryWithPool ¶
func NewRedisEntryWithPool(pool *redis.Pool) RedisEntry
func (RedisEntry) Del ¶
func (re RedisEntry) Del(key string) error
func (RedisEntry) HMGet ¶
func (re RedisEntry) HMGet(keys ...interface{}) (map[string]string, error)
func (RedisEntry) HMSet ¶
func (re RedisEntry) HMSet(kvs ...interface{}) error
func (RedisEntry) ObtainLock ¶
func (RedisEntry) ReleaseLock ¶
func (re RedisEntry) ReleaseLock(key, val, publishKey, publishMsg string) (int, error)
func (RedisEntry) SubscribeAndReceiveMessage ¶
Click to show internal directories.
Click to hide internal directories.