redis

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: Apache-2.0 Imports: 9 Imported by: 3

README

Documentation

Overview

Package redis provides operations for redis commands.

Package redis is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	Recorder func(Driver) Driver
	Replayer func(Driver) Driver
)

Functions

func ErrNil

func ErrNil() error

ErrNil returns the `errNil` error.

func IsErrNil

func IsErrNil(err error) bool

IsErrNil returns whether err is the `errNil` error.

func IsOK

func IsOK(s string) bool

IsOK returns whether s equals "OK".

Types

type Case

type Case struct {
	Func func(t *testing.T, ctx context.Context, c *Client)
	Skip bool
	Data string
}

type Cases

type Cases struct{}

func (*Cases) Append

func (c *Cases) Append() *Case

func (*Cases) BitCount

func (c *Cases) BitCount() *Case

func (*Cases) BitOpAnd

func (c *Cases) BitOpAnd() *Case

func (*Cases) BitPos

func (c *Cases) BitPos() *Case

func (*Cases) Decr

func (c *Cases) Decr() *Case

func (*Cases) DecrBy

func (c *Cases) DecrBy() *Case

func (*Cases) Del

func (c *Cases) Del() *Case

func (*Cases) Dump

func (c *Cases) Dump() *Case

func (*Cases) Exists

func (c *Cases) Exists() *Case

func (*Cases) Expire

func (c *Cases) Expire() *Case

func (*Cases) ExpireAt

func (c *Cases) ExpireAt() *Case

func (*Cases) Get

func (c *Cases) Get() *Case

func (*Cases) GetBit

func (c *Cases) GetBit() *Case

func (*Cases) GetDel

func (c *Cases) GetDel() *Case

func (*Cases) GetRange

func (c *Cases) GetRange() *Case

func (*Cases) GetSet

func (c *Cases) GetSet() *Case

func (*Cases) HDel

func (c *Cases) HDel() *Case

func (*Cases) HExists

func (c *Cases) HExists() *Case

func (*Cases) HGet

func (c *Cases) HGet() *Case

func (*Cases) HGetAll

func (c *Cases) HGetAll() *Case

func (*Cases) HIncrBy

func (c *Cases) HIncrBy() *Case

func (*Cases) HIncrByFloat

func (c *Cases) HIncrByFloat() *Case

func (*Cases) HKeys

func (c *Cases) HKeys() *Case

func (*Cases) HLen

func (c *Cases) HLen() *Case

func (*Cases) HMGet

func (c *Cases) HMGet() *Case

func (*Cases) HSet

func (c *Cases) HSet() *Case

func (*Cases) HSetNX

func (c *Cases) HSetNX() *Case

func (*Cases) HStrLen

func (c *Cases) HStrLen() *Case

func (*Cases) HVals

func (c *Cases) HVals() *Case

func (*Cases) Incr

func (c *Cases) Incr() *Case

func (*Cases) IncrBy

func (c *Cases) IncrBy() *Case

func (*Cases) IncrByFloat

func (c *Cases) IncrByFloat() *Case

func (*Cases) Keys

func (c *Cases) Keys() *Case

func (*Cases) LIndex

func (c *Cases) LIndex() *Case

func (*Cases) LInsert

func (c *Cases) LInsert() *Case

func (*Cases) LLen

func (c *Cases) LLen() *Case

func (*Cases) LMove

func (c *Cases) LMove() *Case

func (*Cases) LPop

func (c *Cases) LPop() *Case

func (*Cases) LPos

func (c *Cases) LPos() *Case

func (*Cases) LPush

func (c *Cases) LPush() *Case

func (*Cases) LPushX

func (c *Cases) LPushX() *Case

func (*Cases) LRange

func (c *Cases) LRange() *Case

func (*Cases) LRem

func (c *Cases) LRem() *Case

func (*Cases) LSet

func (c *Cases) LSet() *Case

func (*Cases) LTrim

func (c *Cases) LTrim() *Case

func (*Cases) MGet

func (c *Cases) MGet() *Case

func (*Cases) MSet

func (c *Cases) MSet() *Case

func (*Cases) MSetNX

func (c *Cases) MSetNX() *Case

func (*Cases) PExpire

func (c *Cases) PExpire() *Case

func (*Cases) PExpireAt

func (c *Cases) PExpireAt() *Case

func (*Cases) PSetEX

func (c *Cases) PSetEX() *Case

func (*Cases) PTTL

func (c *Cases) PTTL() *Case

func (*Cases) Persist

func (c *Cases) Persist() *Case

func (*Cases) RPop

func (c *Cases) RPop() *Case

func (*Cases) RPopLPush

func (c *Cases) RPopLPush() *Case

func (*Cases) RPush

func (c *Cases) RPush() *Case

func (*Cases) RPushX

func (c *Cases) RPushX() *Case

func (*Cases) Rename

func (c *Cases) Rename() *Case

func (*Cases) RenameNX

func (c *Cases) RenameNX() *Case

func (*Cases) SAdd

func (c *Cases) SAdd() *Case

func (*Cases) SCard

func (c *Cases) SCard() *Case

func (*Cases) SDiff

func (c *Cases) SDiff() *Case

func (*Cases) SDiffStore

func (c *Cases) SDiffStore() *Case

func (*Cases) SInter

func (c *Cases) SInter() *Case

func (*Cases) SInterStore

func (c *Cases) SInterStore() *Case

func (*Cases) SIsMember

func (c *Cases) SIsMember() *Case

func (*Cases) SMIsMember

func (c *Cases) SMIsMember() *Case

func (*Cases) SMembers

func (c *Cases) SMembers() *Case

func (*Cases) SMove

func (c *Cases) SMove() *Case

func (*Cases) SPop

func (c *Cases) SPop() *Case

func (*Cases) SRandMember

func (c *Cases) SRandMember() *Case

func (*Cases) SRem

func (c *Cases) SRem() *Case

func (*Cases) SUnion

func (c *Cases) SUnion() *Case

func (*Cases) SUnionStore

func (c *Cases) SUnionStore() *Case

func (*Cases) Set

func (c *Cases) Set() *Case

func (*Cases) SetBit

func (c *Cases) SetBit() *Case

func (*Cases) SetEX

func (c *Cases) SetEX() *Case

func (*Cases) SetNX

func (c *Cases) SetNX() *Case

func (*Cases) SetRange

func (c *Cases) SetRange() *Case

func (*Cases) StrLen

func (c *Cases) StrLen() *Case

func (*Cases) TTL

func (c *Cases) TTL() *Case

func (*Cases) Touch

func (c *Cases) Touch() *Case

func (*Cases) Type

func (c *Cases) Type() *Case

func (*Cases) ZAdd

func (c *Cases) ZAdd() *Case

func (*Cases) ZCard

func (c *Cases) ZCard() *Case

func (*Cases) ZCount

func (c *Cases) ZCount() *Case

func (*Cases) ZDiff

func (c *Cases) ZDiff() *Case

func (*Cases) ZIncrBy

func (c *Cases) ZIncrBy() *Case

func (*Cases) ZInter

func (c *Cases) ZInter() *Case

func (*Cases) ZLexCount

func (c *Cases) ZLexCount() *Case

func (*Cases) ZMScore

func (c *Cases) ZMScore() *Case

func (*Cases) ZPopMax

func (c *Cases) ZPopMax() *Case

func (*Cases) ZPopMin

func (c *Cases) ZPopMin() *Case

func (*Cases) ZRandMember

func (c *Cases) ZRandMember() *Case

func (*Cases) ZRange

func (c *Cases) ZRange() *Case

func (*Cases) ZRangeByLex

func (c *Cases) ZRangeByLex() *Case

func (*Cases) ZRangeByScore

func (c *Cases) ZRangeByScore() *Case

func (*Cases) ZRank

func (c *Cases) ZRank() *Case

func (*Cases) ZRem

func (c *Cases) ZRem() *Case

func (*Cases) ZRemRangeByLex

func (c *Cases) ZRemRangeByLex() *Case

func (*Cases) ZRemRangeByRank

func (c *Cases) ZRemRangeByRank() *Case

func (*Cases) ZRemRangeByScore

func (c *Cases) ZRemRangeByScore() *Case

func (*Cases) ZRevRange

func (c *Cases) ZRevRange() *Case

func (*Cases) ZRevRangeByLex

func (c *Cases) ZRevRangeByLex() *Case

func (*Cases) ZRevRangeByScore

func (c *Cases) ZRevRangeByScore() *Case

func (*Cases) ZRevRank

func (c *Cases) ZRevRank() *Case

func (*Cases) ZScore

func (c *Cases) ZScore() *Case

func (*Cases) ZUnion

func (c *Cases) ZUnion() *Case

func (*Cases) ZUnionStore

func (c *Cases) ZUnionStore() *Case

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides operations for redis commands.

func NewClient

func NewClient(driver Driver) *Client

NewClient returns a new *Client.

func (*Client) Append

func (c *Client) Append(ctx context.Context, key, value string) (int64, error)

Append https://redis.io/commands/append Command: APPEND key value Integer reply: the length of the string after the append operation.

func (*Client) BitCount

func (c *Client) BitCount(ctx context.Context, key string, args ...interface{}) (int64, error)

BitCount https://redis.io/commands/bitcount Command: BITCOUNT key [start end] Integer reply: The number of bits set to 1.

func (*Client) BitOpAnd

func (c *Client) BitOpAnd(ctx context.Context, destKey string, keys ...string) (int64, error)

BitOpAnd https://redis.io/commands/bitop Command: BITOP AND destkey srckey1 srckey2 srckey3 ... srckeyN Integer reply: The size of the string stored in the destination key, that is equal to the size of the longest input string.

func (*Client) BitOpNot

func (c *Client) BitOpNot(ctx context.Context, destKey string, key string) (int64, error)

BitOpNot https://redis.io/commands/bitop Command: BITOP NOT destkey srckey Integer reply: The size of the string stored in the destination key, that is equal to the size of the longest input string.

func (*Client) BitOpOr

func (c *Client) BitOpOr(ctx context.Context, destKey string, keys ...string) (int64, error)

BitOpOr https://redis.io/commands/bitop Command: BITOP OR destkey srckey1 srckey2 srckey3 ... srckeyN Integer reply: The size of the string stored in the destination key, that is equal to the size of the longest input string.

func (*Client) BitOpXor

func (c *Client) BitOpXor(ctx context.Context, destKey string, keys ...string) (int64, error)

BitOpXor https://redis.io/commands/bitop Command: BITOP XOR destkey srckey1 srckey2 srckey3 ... srckeyN Integer reply: The size of the string stored in the destination key, that is equal to the size of the longest input string.

func (*Client) BitPos

func (c *Client) BitPos(ctx context.Context, key string, bit int64, args ...interface{}) (int64, error)

BitPos https://redis.io/commands/bitpos Command: BITPOS key bit [start [end]] Integer reply: The command returns the position of the first bit set to 1 or 0 according to the request.

func (*Client) Decr

func (c *Client) Decr(ctx context.Context, key string) (int64, error)

Decr https://redis.io/commands/decr Command: DECR key Integer reply: the value of key after the decrement

func (*Client) DecrBy

func (c *Client) DecrBy(ctx context.Context, key string, decrement int64) (int64, error)

DecrBy https://redis.io/commands/decrby Command: DECRBY key decrement Integer reply: the value of key after the decrement.

func (*Client) Del

func (c *Client) Del(ctx context.Context, keys ...string) (int64, error)

Del https://redis.io/commands/del Command: DEL key [key ...] Integer reply: The number of keys that were removed.

func (*Client) Dump

func (c *Client) Dump(ctx context.Context, key string) (string, error)

Dump https://redis.io/commands/dump Command: DUMP key Bulk string reply: the serialized value. If key does not exist a nil bulk reply is returned.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, keys ...string) (int64, error)

Exists https://redis.io/commands/exists Command: EXISTS key [key ...] Integer reply: The number of keys existing among the ones specified as arguments. Keys mentioned multiple times and existing are counted multiple times.

func (*Client) Expire

func (c *Client) Expire(ctx context.Context, key string, expire int64, args ...interface{}) (int64, error)

Expire https://redis.io/commands/expire Command: EXPIRE key seconds [NX|XX|GT|LT] Integer reply: 1 if the timeout was set, 0 if the timeout was not set.

func (*Client) ExpireAt

func (c *Client) ExpireAt(ctx context.Context, key string, expireAt int64, args ...interface{}) (int64, error)

ExpireAt https://redis.io/commands/expireat Command: EXPIREAT key timestamp [NX|XX|GT|LT] Integer reply: 1 if the timeout was set, 0 if the timeout was not set.

func (*Client) Float

func (c *Client) Float(ctx context.Context, args ...interface{}) (float64, error)

Float executes a command whose reply is a `float64`.

func (*Client) FloatSlice

func (c *Client) FloatSlice(ctx context.Context, args ...interface{}) ([]float64, error)

FloatSlice executes a command whose reply is a `[]float64`.

func (*Client) FlushAll

func (c *Client) FlushAll(ctx context.Context, args ...interface{}) (string, error)

FlushAll https://redis.io/commands/flushall Command: FLUSHALL [ASYNC|SYNC] Simple string reply

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (string, error)

Get https://redis.io/commands/get Command: GET key Bulk string reply: the value of key, or nil when key does not exist.

func (*Client) GetBit

func (c *Client) GetBit(ctx context.Context, key string, offset int64) (int64, error)

GetBit https://redis.io/commands/getbit Command: GETBIT key offset Integer reply: the bit value stored at offset.

func (*Client) GetDel

func (c *Client) GetDel(ctx context.Context, key string) (string, error)

GetDel https://redis.io/commands/getdel Command: GETDEL key Bulk string reply: the value of key, nil when key does not exist, or an error if the key's value type isn't a string.

func (*Client) GetEx

func (c *Client) GetEx(ctx context.Context, key string, args ...interface{}) (string, error)

GetEx https://redis.io/commands/getex Command: GETEX key [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|PERSIST] Bulk string reply: the value of key, or nil when key does not exist.

func (*Client) GetRange

func (c *Client) GetRange(ctx context.Context, key string, start, end int64) (string, error)

GetRange https://redis.io/commands/getrange Command: GETRANGE key start end Bulk string reply

func (*Client) GetSet

func (c *Client) GetSet(ctx context.Context, key string, value interface{}) (string, error)

GetSet https://redis.io/commands/getset Command: GETSET key value Bulk string reply: the old value stored at key, or nil when key did not exist.

func (*Client) HDel

func (c *Client) HDel(ctx context.Context, key string, fields ...string) (int64, error)

HDel https://redis.io/commands/hdel Command: HDEL key field [field ...] Integer reply: the number of fields that were removed from the hash, not including specified but non-existing fields.

func (*Client) HExists

func (c *Client) HExists(ctx context.Context, key, field string) (int64, error)

HExists https://redis.io/commands/hexists Command: HEXISTS key field Integer reply: 1 if the hash contains field, 0 if the hash does not contain field, or key does not exist.

func (*Client) HGet

func (c *Client) HGet(ctx context.Context, key string, field string) (string, error)

HGet https://redis.io/commands/hget Command: HGET key field Bulk string reply: the value associated with field, or nil when field is not present in the hash or key does not exist.

func (*Client) HGetAll

func (c *Client) HGetAll(ctx context.Context, key string) (map[string]string, error)

HGetAll https://redis.io/commands/hgetall Command: HGETALL key Array reply: list of fields and their values stored in the hash, or an empty list when key does not exist.

func (*Client) HIncrBy

func (c *Client) HIncrBy(ctx context.Context, key, field string, incr int64) (int64, error)

HIncrBy https://redis.io/commands/hincrby Command: HINCRBY key field increment Integer reply: the value at field after the increment operation.

func (*Client) HIncrByFloat

func (c *Client) HIncrByFloat(ctx context.Context, key, field string, incr float64) (float64, error)

HIncrByFloat https://redis.io/commands/hincrbyfloat Command: HINCRBYFLOAT key field increment Bulk string reply: the value of field after the increment.

func (*Client) HKeys

func (c *Client) HKeys(ctx context.Context, key string) ([]string, error)

HKeys https://redis.io/commands/hkeys Command: HKEYS key Array reply: list of fields in the hash, or an empty list when key does not exist.

func (*Client) HLen

func (c *Client) HLen(ctx context.Context, key string) (int64, error)

HLen https://redis.io/commands/hlen Command: HLEN key Integer reply: number of fields in the hash, or 0 when key does not exist.

func (*Client) HMGet

func (c *Client) HMGet(ctx context.Context, key string, fields ...string) ([]interface{}, error)

HMGet https://redis.io/commands/hmget Command: HMGET key field [field ...] Array reply: list of values associated with the given fields, in the same order as they are requested.

func (*Client) HSet

func (c *Client) HSet(ctx context.Context, key string, args ...interface{}) (int64, error)

HSet https://redis.io/commands/hset Command: HSET key field value [field value ...] Integer reply: The number of fields that were added.

func (*Client) HSetNX

func (c *Client) HSetNX(ctx context.Context, key, field string, value interface{}) (int64, error)

HSetNX https://redis.io/commands/hsetnx Command: HSETNX key field value Integer reply: 1 if field is a new field in the hash and value was set, 0 if field already exists in the hash and no operation was performed.

func (*Client) HStrLen

func (c *Client) HStrLen(ctx context.Context, key, field string) (int64, error)

HStrLen https://redis.io/commands/hstrlen Command: HSTRLEN key field Integer reply: the string length of the value associated with field, or zero when field is not present in the hash or key does not exist at all.

func (*Client) HVals

func (c *Client) HVals(ctx context.Context, key string) ([]string, error)

HVals https://redis.io/commands/hvals Command: HVALS key Array reply: list of values in the hash, or an empty list when key does not exist.

func (*Client) Incr

func (c *Client) Incr(ctx context.Context, key string) (int64, error)

Incr https://redis.io/commands/incr Command: INCR key Integer reply: the value of key after the increment

func (*Client) IncrBy

func (c *Client) IncrBy(ctx context.Context, key string, value int64) (int64, error)

IncrBy https://redis.io/commands/incrby Command: INCRBY key increment Integer reply: the value of key after the increment.

func (*Client) IncrByFloat

func (c *Client) IncrByFloat(ctx context.Context, key string, value float64) (float64, error)

IncrByFloat https://redis.io/commands/incrbyfloat Command: INCRBYFLOAT key increment Bulk string reply: the value of key after the increment.

func (*Client) Int

func (c *Client) Int(ctx context.Context, args ...interface{}) (int64, error)

Int executes a command whose reply is a `int64`.

func (*Client) IntSlice

func (c *Client) IntSlice(ctx context.Context, args ...interface{}) ([]int64, error)

IntSlice executes a command whose reply is a `[]int64`.

func (*Client) Keys

func (c *Client) Keys(ctx context.Context, pattern string) ([]string, error)

Keys https://redis.io/commands/keys Command: KEYS pattern Array reply: list of keys matching pattern.

func (*Client) LIndex

func (c *Client) LIndex(ctx context.Context, key string, index int64) (string, error)

LIndex https://redis.io/commands/lindex Command: LINDEX key index Bulk string reply: the requested element, or nil when index is out of range.

func (*Client) LInsertAfter

func (c *Client) LInsertAfter(ctx context.Context, key string, pivot, value interface{}) (int64, error)

LInsertAfter https://redis.io/commands/linsert Command: LINSERT key BEFORE|AFTER pivot element Integer reply: the length of the list after the insert operation, or -1 when the value pivot was not found.

func (*Client) LInsertBefore

func (c *Client) LInsertBefore(ctx context.Context, key string, pivot, value interface{}) (int64, error)

LInsertBefore https://redis.io/commands/linsert Command: LINSERT key BEFORE|AFTER pivot element Integer reply: the length of the list after the insert operation, or -1 when the value pivot was not found.

func (*Client) LLen

func (c *Client) LLen(ctx context.Context, key string) (int64, error)

LLen https://redis.io/commands/llen Command: LLEN key Integer reply: the length of the list at key.

func (*Client) LMove

func (c *Client) LMove(ctx context.Context, source, destination, srcPos, destPos string) (string, error)

LMove https://redis.io/commands/lmove Command: LMOVE source destination LEFT|RIGHT LEFT|RIGHT Bulk string reply: the element being popped and pushed.

func (*Client) LPop

func (c *Client) LPop(ctx context.Context, key string) (string, error)

LPop https://redis.io/commands/lpop Command: LPOP key [count] Bulk string reply: the value of the first element, or nil when key does not exist.

func (*Client) LPopN

func (c *Client) LPopN(ctx context.Context, key string, count int) ([]string, error)

LPopN https://redis.io/commands/lpop Command: LPOP key [count] Array reply: list of popped elements, or nil when key does not exist.

func (*Client) LPos

func (c *Client) LPos(ctx context.Context, key string, value interface{}, args ...interface{}) (int64, error)

LPos https://redis.io/commands/lpos Command: LPOS key element [RANK rank] [COUNT num-matches] [MAXLEN len] The command returns the integer representing the matching element, or nil if there is no match. However, if the COUNT option is given the command returns an array (empty if there are no matches).

func (*Client) LPosN

func (c *Client) LPosN(ctx context.Context, key string, value interface{}, count int64, args ...interface{}) ([]int64, error)

LPosN https://redis.io/commands/lpos Command: LPOS key element [RANK rank] [COUNT num-matches] [MAXLEN len] The command returns the integer representing the matching element, or nil if there is no match. However, if the COUNT option is given the command returns an array (empty if there are no matches).

func (*Client) LPush

func (c *Client) LPush(ctx context.Context, key string, values ...interface{}) (int64, error)

LPush https://redis.io/commands/lpush Command: LPUSH key element [element ...] Integer reply: the length of the list after the push operations.

func (*Client) LPushX

func (c *Client) LPushX(ctx context.Context, key string, values ...interface{}) (int64, error)

LPushX https://redis.io/commands/lpushx Command: LPUSHX key element [element ...] Integer reply: the length of the list after the push operation.

func (*Client) LRange

func (c *Client) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)

LRange https://redis.io/commands/lrange Command: LRANGE key start stop Array reply: list of elements in the specified range.

func (*Client) LRem

func (c *Client) LRem(ctx context.Context, key string, count int64, value interface{}) (int64, error)

LRem https://redis.io/commands/lrem Command: LREM key count element Integer reply: the number of removed elements.

func (*Client) LSet

func (c *Client) LSet(ctx context.Context, key string, index int64, value interface{}) (string, error)

LSet https://redis.io/commands/lset Command: LSET key index element Simple string reply

func (*Client) LTrim

func (c *Client) LTrim(ctx context.Context, key string, start, stop int64) (string, error)

LTrim https://redis.io/commands/ltrim Command: LTRIM key start stop Simple string reply

func (*Client) MGet

func (c *Client) MGet(ctx context.Context, keys ...string) ([]interface{}, error)

MGet https://redis.io/commands/mget Command: MGET key [key ...] Array reply: list of values at the specified keys.

func (*Client) MSet

func (c *Client) MSet(ctx context.Context, args ...interface{}) (string, error)

MSet https://redis.io/commands/mset Command: MSET key value [key value ...] Simple string reply: always OK since MSET can't fail.

func (*Client) MSetNX

func (c *Client) MSetNX(ctx context.Context, args ...interface{}) (int64, error)

MSetNX https://redis.io/commands/msetnx Command: MSETNX key value [key value ...] MSETNX is atomic, so all given keys are set at once Integer reply: 1 if the all the keys were set, 0 if no key was set (at least one key already existed).

func (*Client) PExpire

func (c *Client) PExpire(ctx context.Context, key string, expire int64, args ...interface{}) (int64, error)

PExpire https://redis.io/commands/pexpire Command: PEXPIRE key milliseconds [NX|XX|GT|LT] Integer reply: 1 if the timeout was set, 0 if the timeout was not set.

func (*Client) PExpireAt

func (c *Client) PExpireAt(ctx context.Context, key string, expireAt int64, args ...interface{}) (int64, error)

PExpireAt https://redis.io/commands/pexpireat Command: PEXPIREAT key milliseconds-timestamp [NX|XX|GT|LT] Integer reply: 1 if the timeout was set, 0 if the timeout was not set.

func (*Client) PSetEX

func (c *Client) PSetEX(ctx context.Context, key string, value interface{}, expire int64) (string, error)

PSetEX https://redis.io/commands/psetex Command: PSETEX key milliseconds value Simple string reply

func (*Client) PTTL

func (c *Client) PTTL(ctx context.Context, key string) (int64, error)

PTTL https://redis.io/commands/pttl Command: PTTL key Integer reply: TTL in milliseconds, -1 if the key exists but has no associated expire, -2 if the key does not exist.

func (*Client) Persist

func (c *Client) Persist(ctx context.Context, key string) (int64, error)

Persist https://redis.io/commands/persist Command: PERSIST key Integer reply: 1 if the timeout was removed, 0 if key does not exist or does not have an associated timeout.

func (*Client) RPop

func (c *Client) RPop(ctx context.Context, key string) (string, error)

RPop https://redis.io/commands/rpop Command: RPOP key [count] Bulk string reply: the value of the last element, or nil when key does not exist.

func (*Client) RPopLPush

func (c *Client) RPopLPush(ctx context.Context, source, destination string) (string, error)

RPopLPush https://redis.io/commands/rpoplpush Command: RPOPLPUSH source destination Bulk string reply: the element being popped and pushed.

func (*Client) RPopN

func (c *Client) RPopN(ctx context.Context, key string, count int) ([]string, error)

RPopN https://redis.io/commands/rpop Command: RPOP key [count] Array reply: list of popped elements, or nil when key does not exist.

func (*Client) RPush

func (c *Client) RPush(ctx context.Context, key string, values ...interface{}) (int64, error)

RPush https://redis.io/commands/rpush Command: RPUSH key element [element ...] Integer reply: the length of the list after the push operation.

func (*Client) RPushX

func (c *Client) RPushX(ctx context.Context, key string, values ...interface{}) (int64, error)

RPushX https://redis.io/commands/rpushx Command: RPUSHX key element [element ...] Integer reply: the length of the list after the push operation.

func (*Client) RandomKey

func (c *Client) RandomKey(ctx context.Context) (string, error)

RandomKey https://redis.io/commands/randomkey Command: RANDOMKEY Bulk string reply: the random key, or nil when the database is empty.

func (*Client) Rename

func (c *Client) Rename(ctx context.Context, key, newKey string) (string, error)

Rename https://redis.io/commands/rename Command: RENAME key newkey Simple string reply.

func (*Client) RenameNX

func (c *Client) RenameNX(ctx context.Context, key, newKey string) (int64, error)

RenameNX https://redis.io/commands/renamenx Command: RENAMENX key newkey Integer reply: 1 if key was renamed to newKey, 0 if newKey already exists.

func (*Client) SAdd

func (c *Client) SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)

SAdd https://redis.io/commands/sadd Command: SADD key member [member ...] Integer reply: the number of elements that were added to the set, not including all the elements already present in the set.

func (*Client) SCard

func (c *Client) SCard(ctx context.Context, key string) (int64, error)

SCard https://redis.io/commands/scard Command: SCARD key Integer reply: the cardinality (number of elements) of the set, or 0 if key does not exist.

func (*Client) SDiff

func (c *Client) SDiff(ctx context.Context, keys ...string) ([]string, error)

SDiff https://redis.io/commands/sdiff Command: SDIFF key [key ...] Array reply: list with members of the resulting set.

func (*Client) SDiffStore

func (c *Client) SDiffStore(ctx context.Context, destination string, keys ...string) (int64, error)

SDiffStore https://redis.io/commands/sdiffstore Command: SDIFFSTORE destination key [key ...] Integer reply: the number of elements in the resulting set.

func (*Client) SInter

func (c *Client) SInter(ctx context.Context, keys ...string) ([]string, error)

SInter https://redis.io/commands/sinter Command: SINTER key [key ...] Array reply: list with members of the resulting set.

func (*Client) SInterStore

func (c *Client) SInterStore(ctx context.Context, destination string, keys ...string) (int64, error)

SInterStore https://redis.io/commands/sinterstore Command: SINTERSTORE destination key [key ...] Integer reply: the number of elements in the resulting set.

func (*Client) SIsMember

func (c *Client) SIsMember(ctx context.Context, key string, member interface{}) (int64, error)

SIsMember https://redis.io/commands/sismember Command: SISMEMBER key member Integer reply: 1 if the element is a member of the set, 0 if the element is not a member of the set, or if key does not exist.

func (*Client) SMIsMember

func (c *Client) SMIsMember(ctx context.Context, key string, members ...interface{}) ([]int64, error)

SMIsMember https://redis.io/commands/smismember Command: SMISMEMBER key member [member ...] Array reply: list representing the membership of the given elements, in the same order as they are requested.

func (*Client) SMembers

func (c *Client) SMembers(ctx context.Context, key string) ([]string, error)

SMembers https://redis.io/commands/smembers Command: SMEMBERS key Array reply: all elements of the set.

func (*Client) SMove

func (c *Client) SMove(ctx context.Context, source, destination string, member interface{}) (int64, error)

SMove https://redis.io/commands/smove Command: SMOVE source destination member Integer reply: 1 if the element is moved, 0 if the element is not a member of source and no operation was performed.

func (*Client) SPop

func (c *Client) SPop(ctx context.Context, key string) (string, error)

SPop https://redis.io/commands/spop Command: SPOP key [count] Bulk string reply: the removed member, or nil when key does not exist.

func (*Client) SPopN

func (c *Client) SPopN(ctx context.Context, key string, count int64) ([]string, error)

SPopN https://redis.io/commands/spop Command: SPOP key [count] Array reply: the removed members, or an empty array when key does not exist.

func (*Client) SRandMember

func (c *Client) SRandMember(ctx context.Context, key string) (string, error)

SRandMember https://redis.io/commands/srandmember Command: SRANDMEMBER key [count] Returns a Bulk Reply with the randomly selected element, or nil when key does not exist.

func (*Client) SRandMemberN

func (c *Client) SRandMemberN(ctx context.Context, key string, count int64) ([]string, error)

SRandMemberN https://redis.io/commands/srandmember Command: SRANDMEMBER key [count] Returns an array of elements, or an empty array when key does not exist.

func (*Client) SRem

func (c *Client) SRem(ctx context.Context, key string, members ...interface{}) (int64, error)

SRem https://redis.io/commands/srem Command: SREM key member [member ...] Integer reply: the number of members that were removed from the set, not including non-existing members.

func (*Client) SUnion

func (c *Client) SUnion(ctx context.Context, keys ...string) ([]string, error)

SUnion https://redis.io/commands/sunion Command: SUNION key [key ...] Array reply: list with members of the resulting set.

func (*Client) SUnionStore

func (c *Client) SUnionStore(ctx context.Context, destination string, keys ...string) (int64, error)

SUnionStore https://redis.io/commands/sunionstore Command: SUNIONSTORE destination key [key ...] Integer reply: the number of elements in the resulting set.

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, value interface{}, args ...interface{}) (string, error)

Set https://redis.io/commands/set Command: SET key value [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|KEEPTTL] [NX|XX] [GET] Simple string reply: OK if SET was executed correctly.

func (*Client) SetBit

func (c *Client) SetBit(ctx context.Context, key string, offset int64, value int) (int64, error)

SetBit https://redis.io/commands/setbit Command: SETBIT key offset value Integer reply: the original bit value stored at offset.

func (*Client) SetEX

func (c *Client) SetEX(ctx context.Context, key string, value interface{}, expire int64) (string, error)

SetEX https://redis.io/commands/setex Command: SETEX key seconds value Simple string reply

func (*Client) SetNX

func (c *Client) SetNX(ctx context.Context, key string, value interface{}) (int64, error)

SetNX https://redis.io/commands/setnx Command: SETNX key value Integer reply: 1 if the key was set, 0 if the key was not set.

func (*Client) SetRange

func (c *Client) SetRange(ctx context.Context, key string, offset int64, value string) (int64, error)

SetRange https://redis.io/commands/setrange Command: SETRANGE key offset value Integer reply: the length of the string after it was modified by the command.

func (*Client) Slice

func (c *Client) Slice(ctx context.Context, args ...interface{}) ([]interface{}, error)

Slice executes a command whose reply is a `[]interface{}`.

func (*Client) StrLen

func (c *Client) StrLen(ctx context.Context, key string) (int64, error)

StrLen https://redis.io/commands/strlen Command: STRLEN key Integer reply: the length of the string at key, or 0 when key does not exist.

func (*Client) String

func (c *Client) String(ctx context.Context, args ...interface{}) (string, error)

String executes a command whose reply is a `string`.

func (*Client) StringMap

func (c *Client) StringMap(ctx context.Context, args ...interface{}) (map[string]string, error)

StringMap executes a command whose reply is a `map[string]string`.

func (*Client) StringSlice

func (c *Client) StringSlice(ctx context.Context, args ...interface{}) ([]string, error)

StringSlice executes a command whose reply is a `[]string`.

func (*Client) TTL

func (c *Client) TTL(ctx context.Context, key string) (int64, error)

TTL https://redis.io/commands/ttl Command: TTL key Integer reply: TTL in seconds, -1 if the key exists but has no associated expire, -2 if the key does not exist.

func (*Client) Touch

func (c *Client) Touch(ctx context.Context, keys ...string) (int64, error)

Touch https://redis.io/commands/touch Command: TOUCH key [key ...] Integer reply: The number of keys that were touched.

func (*Client) Type

func (c *Client) Type(ctx context.Context, key string) (string, error)

Type https://redis.io/commands/type Command: TYPE key Simple string reply: type of key, or none when key does not exist.

func (*Client) ZAdd

func (c *Client) ZAdd(ctx context.Context, key string, args ...interface{}) (int64, error)

ZAdd https://redis.io/commands/zadd Command: ZADD key [NX|XX] [GT|LT] [CH] [INCR] score member [score member ...] Integer reply, the number of elements added to the sorted set (excluding score updates).

func (*Client) ZCard

func (c *Client) ZCard(ctx context.Context, key string) (int64, error)

ZCard https://redis.io/commands/zcard Command: ZCARD key Integer reply: the cardinality (number of elements) of the sorted set, or 0 if key does not exist.

func (*Client) ZCount

func (c *Client) ZCount(ctx context.Context, key, min, max string) (int64, error)

ZCount https://redis.io/commands/zcount Command: ZCOUNT key min max Integer reply: the number of elements in the specified score range.

func (*Client) ZDiff

func (c *Client) ZDiff(ctx context.Context, keys ...string) ([]string, error)

ZDiff https://redis.io/commands/zdiff Command: ZDIFF numkeys key [key ...] [WITHSCORES] Array reply: the result of the difference.

func (*Client) ZDiffWithScores

func (c *Client) ZDiffWithScores(ctx context.Context, keys ...string) ([]ZItem, error)

ZDiffWithScores https://redis.io/commands/zdiff Command: ZDIFF numkeys key [key ...] [WITHSCORES] Array reply: the result of the difference.

func (*Client) ZIncrBy

func (c *Client) ZIncrBy(ctx context.Context, key string, increment float64, member string) (float64, error)

ZIncrBy https://redis.io/commands/zincrby Command: ZINCRBY key increment member Bulk string reply: the new score of member (a double precision floating point number), represented as string.

func (*Client) ZInter

func (c *Client) ZInter(ctx context.Context, args ...interface{}) ([]string, error)

ZInter https://redis.io/commands/zinter Command: ZINTER numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] [WITHSCORES] Array reply: the result of intersection.

func (*Client) ZInterWithScores

func (c *Client) ZInterWithScores(ctx context.Context, args ...interface{}) ([]ZItem, error)

ZInterWithScores https://redis.io/commands/zinter Command: ZINTER numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] [WITHSCORES] Array reply: the result of intersection.

func (*Client) ZItemSlice

func (c *Client) ZItemSlice(ctx context.Context, args ...interface{}) ([]ZItem, error)

ZItemSlice executes a command whose reply is a `[]ZItem`.

func (*Client) ZLexCount

func (c *Client) ZLexCount(ctx context.Context, key, min, max string) (int64, error)

ZLexCount https://redis.io/commands/zlexcount Command: ZLEXCOUNT key min max Integer reply: the number of elements in the specified score range.

func (*Client) ZMScore

func (c *Client) ZMScore(ctx context.Context, key string, members ...string) ([]float64, error)

ZMScore https://redis.io/commands/zmscore Command: ZMSCORE key member [member ...] Array reply: list of scores or nil associated with the specified member values (a double precision floating point number), represented as strings.

func (*Client) ZPopMax

func (c *Client) ZPopMax(ctx context.Context, key string) ([]ZItem, error)

ZPopMax https://redis.io/commands/zpopmax Command: ZPOPMAX key [count] Array reply: list of popped elements and scores.

func (*Client) ZPopMaxN

func (c *Client) ZPopMaxN(ctx context.Context, key string, count int64) ([]ZItem, error)

ZPopMaxN https://redis.io/commands/zpopmax Command: ZPOPMAX key [count] Array reply: list of popped elements and scores.

func (*Client) ZPopMin

func (c *Client) ZPopMin(ctx context.Context, key string) ([]ZItem, error)

ZPopMin https://redis.io/commands/zpopmin Command: ZPOPMIN key [count] Array reply: list of popped elements and scores.

func (*Client) ZPopMinN

func (c *Client) ZPopMinN(ctx context.Context, key string, count int64) ([]ZItem, error)

ZPopMinN https://redis.io/commands/zpopmin Command: ZPOPMIN key [count] Array reply: list of popped elements and scores.

func (*Client) ZRandMember

func (c *Client) ZRandMember(ctx context.Context, key string) (string, error)

ZRandMember https://redis.io/commands/zrandmember Command: ZRANDMEMBER key [count [WITHSCORES]] Bulk Reply with the randomly selected element, or nil when key does not exist.

func (*Client) ZRandMemberN

func (c *Client) ZRandMemberN(ctx context.Context, key string, count int) ([]string, error)

ZRandMemberN https://redis.io/commands/zrandmember Command: ZRANDMEMBER key [count [WITHSCORES]] Bulk Reply with the randomly selected element, or nil when key does not exist.

func (*Client) ZRandMemberWithScores

func (c *Client) ZRandMemberWithScores(ctx context.Context, key string, count int) ([]ZItem, error)

ZRandMemberWithScores https://redis.io/commands/zrandmember Command: ZRANDMEMBER key [count [WITHSCORES]] Bulk Reply with the randomly selected element, or nil when key does not exist.

func (*Client) ZRange

func (c *Client) ZRange(ctx context.Context, key string, start, stop int64, args ...interface{}) ([]string, error)

ZRange https://redis.io/commands/zrange Command: ZRANGE key min max [BYSCORE|BYLEX] [REV] [LIMIT offset count] [WITHSCORES] Array reply: list of elements in the specified range.

func (*Client) ZRangeByLex

func (c *Client) ZRangeByLex(ctx context.Context, key string, min, max string, args ...interface{}) ([]string, error)

ZRangeByLex https://redis.io/commands/zrangebylex Command: ZRANGEBYLEX key min max [LIMIT offset count] Array reply: list of elements in the specified score range.

func (*Client) ZRangeByScore

func (c *Client) ZRangeByScore(ctx context.Context, key string, min, max string, args ...interface{}) ([]string, error)

ZRangeByScore https://redis.io/commands/zrangebyscore Command: ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count] Array reply: list of elements in the specified score range.

func (*Client) ZRangeWithScores

func (c *Client) ZRangeWithScores(ctx context.Context, key string, start, stop int64, args ...interface{}) ([]ZItem, error)

ZRangeWithScores https://redis.io/commands/zrange Command: ZRANGE key min max [BYSCORE|BYLEX] [REV] [LIMIT offset count] [WITHSCORES] Array reply: list of elements in the specified range.

func (*Client) ZRank

func (c *Client) ZRank(ctx context.Context, key, member string) (int64, error)

ZRank https://redis.io/commands/zrank Command: ZRANK key member If member exists in the sorted set, Integer reply: the rank of member. If member does not exist in the sorted set or key does not exist, Bulk string reply: nil.

func (*Client) ZRem

func (c *Client) ZRem(ctx context.Context, key string, members ...interface{}) (int64, error)

ZRem https://redis.io/commands/zrem Command: ZREM key member [member ...] Integer reply, The number of members removed from the sorted set, not including non existing members.

func (*Client) ZRemRangeByLex

func (c *Client) ZRemRangeByLex(ctx context.Context, key, min, max string) (int64, error)

ZRemRangeByLex https://redis.io/commands/zremrangebylex Command: ZREMRANGEBYLEX key min max Integer reply: the number of elements removed.

func (*Client) ZRemRangeByRank

func (c *Client) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) (int64, error)

ZRemRangeByRank https://redis.io/commands/zremrangebyrank Command: ZREMRANGEBYRANK key start stop Integer reply: the number of elements removed.

func (*Client) ZRemRangeByScore

func (c *Client) ZRemRangeByScore(ctx context.Context, key, min, max string) (int64, error)

ZRemRangeByScore https://redis.io/commands/zremrangebyscore Command: ZREMRANGEBYSCORE key min max Integer reply: the number of elements removed.

func (*Client) ZRevRange

func (c *Client) ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error)

ZRevRange https://redis.io/commands/zrevrange Command: ZREVRANGE key start stop [WITHSCORES] Array reply: list of elements in the specified range.

func (*Client) ZRevRangeByLex

func (c *Client) ZRevRangeByLex(ctx context.Context, key string, min, max string, args ...interface{}) ([]string, error)

ZRevRangeByLex https://redis.io/commands/zrevrangebylex Command: ZREVRANGEBYLEX key max min [LIMIT offset count] Array reply: list of elements in the specified score range.

func (*Client) ZRevRangeByScore

func (c *Client) ZRevRangeByScore(ctx context.Context, key string, min, max string, args ...interface{}) ([]string, error)

ZRevRangeByScore https://redis.io/commands/zrevrangebyscore Command: ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] Array reply: list of elements in the specified score range.

func (*Client) ZRevRangeWithScores

func (c *Client) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]string, error)

ZRevRangeWithScores https://redis.io/commands/zrevrange Command: ZREVRANGE key start stop [WITHSCORES] Array reply: list of elements in the specified range.

func (*Client) ZRevRank

func (c *Client) ZRevRank(ctx context.Context, key, member string) (int64, error)

ZRevRank https://redis.io/commands/zrevrank Command: ZREVRANK key member If member exists in the sorted set, Integer reply: the rank of member. If member does not exist in the sorted set or key does not exist, Bulk string reply: nil.

func (*Client) ZScore

func (c *Client) ZScore(ctx context.Context, key, member string) (float64, error)

ZScore https://redis.io/commands/zscore Command: ZSCORE key member Bulk string reply: the score of member (a double precision floating point number), represented as string.

func (*Client) ZUnion

func (c *Client) ZUnion(ctx context.Context, args ...interface{}) ([]string, error)

ZUnion https://redis.io/commands/zunion Command: ZUNION numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] [WITHSCORES] Array reply: the result of union.

func (*Client) ZUnionStore

func (c *Client) ZUnionStore(ctx context.Context, dest string, args ...interface{}) (int64, error)

ZUnionStore https://redis.io/commands/zunionstore Command: ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] Integer reply: the number of elements in the resulting sorted set at destination.

func (*Client) ZUnionWithScores

func (c *Client) ZUnionWithScores(ctx context.Context, args ...interface{}) ([]ZItem, error)

ZUnionWithScores https://redis.io/commands/zunion Command: ZUNION numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] [WITHSCORES] Array reply: the result of union.

type Config

type Config struct {
	Host           string `value:"${host:=127.0.0.1}"`
	Port           int    `value:"${port:=6379}"`
	Username       string `value:"${username:=}"`
	Password       string `value:"${password:=}"`
	Database       int    `value:"${database:=0}"`
	Ping           bool   `value:"${ping:=true}"`
	IdleTimeout    int    `value:"${idle-timeout:=0}"`
	ConnectTimeout int    `value:"${connect-timeout:=0}"`
	ReadTimeout    int    `value:"${read-timeout:=0}"`
	WriteTimeout   int    `value:"${write-timeout:=0}"`
}

Config Is the configuration of redis client.

type Driver

type Driver interface {
	Exec(ctx context.Context, args []interface{}) (interface{}, error)
}

type MockDriver

type MockDriver struct {
	// contains filtered or unexported fields
}

MockDriver is a mock of Driver interface.

func NewMockDriver

func NewMockDriver(ctrl *gomock.Controller) *MockDriver

NewMockDriver creates a new mock instance.

func (*MockDriver) EXPECT

func (m *MockDriver) EXPECT() *MockDriverMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDriver) Exec

func (m *MockDriver) Exec(ctx context.Context, args []interface{}) (interface{}, error)

Exec mocks base method.

type MockDriverMockRecorder

type MockDriverMockRecorder struct {
	// contains filtered or unexported fields
}

MockDriverMockRecorder is the mock recorder for MockDriver.

func (*MockDriverMockRecorder) Exec

func (mr *MockDriverMockRecorder) Exec(ctx, args interface{}) *gomock.Call

Exec indicates an expected call of Exec.

type Result

type Result struct {
	Data []string
}

type ZItem

type ZItem struct {
	Member interface{}
	Score  float64
}

Jump to

Keyboard shortcuts

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