redis

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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) Expire

func (re RedisEntry) Expire(key string, second time.Duration) (int64, error)

func (RedisEntry) GetBit

func (re RedisEntry) GetBit(key string, offset uint64) (int64, 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) IncrBy

func (re RedisEntry) IncrBy(key string, increment int64) (int64, error)

func (RedisEntry) ObtainLock

func (re RedisEntry) ObtainLock(key, val string, ttl time.Duration) (int64, error)

func (RedisEntry) PExpire

func (re RedisEntry) PExpire(key string, millisecond time.Duration) (int64, error)

func (RedisEntry) PTTL

func (re RedisEntry) PTTL(key string) (int64, error)

func (RedisEntry) ReleaseLock

func (re RedisEntry) ReleaseLock(key, val, publishKey, publishMsg string) (int, error)

func (RedisEntry) RenewLock

func (re RedisEntry) RenewLock(key, val string, ttl time.Duration) (int, error)

func (RedisEntry) SetBit

func (re RedisEntry) SetBit(key string, offset uint64, value int) error

func (RedisEntry) SubscribeAndReceiveMessage

func (re RedisEntry) SubscribeAndReceiveMessage(publishKey string, timeout time.Duration) (msg string, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL