redis

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Documentation

Overview

Package redis is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrNil

func ErrNil() error

func IsErrNil

func IsErrNil(err error) bool

func IsOK

func IsOK(s string) bool

Types

type BitmapOperations

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

func NewBitmapOperations

func NewBitmapOperations(c *Client) *BitmapOperations

func (*BitmapOperations) BitCount

func (c *BitmapOperations) 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 (*BitmapOperations) BitOpAnd

func (c *BitmapOperations) 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 (*BitmapOperations) BitOpNot

func (c *BitmapOperations) 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 (*BitmapOperations) BitOpOr

func (c *BitmapOperations) 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 (*BitmapOperations) BitOpXor

func (c *BitmapOperations) 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 (*BitmapOperations) BitPos

func (c *BitmapOperations) 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 (*BitmapOperations) GetBit

func (c *BitmapOperations) 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 (*BitmapOperations) SetBit

func (c *BitmapOperations) 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.

type Client

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

func NewClient

func NewClient(conn ConnPool) (*Client, error)

func (*Client) Float

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

func (*Client) FloatSlice

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

func (*Client) Int

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

func (*Client) IntSlice

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

func (*Client) OpsForBitmap

func (c *Client) OpsForBitmap() *BitmapOperations

func (*Client) OpsForHash

func (c *Client) OpsForHash() *HashOperations

func (*Client) OpsForKey

func (c *Client) OpsForKey() *KeyOperations

func (*Client) OpsForList

func (c *Client) OpsForList() *ListOperations

func (*Client) OpsForServer

func (c *Client) OpsForServer() *ServerOperations

func (*Client) OpsForSet

func (c *Client) OpsForSet() *SetOperations

func (*Client) OpsForString

func (c *Client) OpsForString() *StringOperations

func (*Client) OpsForZSet

func (c *Client) OpsForZSet() *ZSetOperations

func (*Client) Slice

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

func (*Client) String

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

func (*Client) StringMap

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

func (*Client) StringSlice

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

func (*Client) ZItemSlice

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

type Config

type Config struct {
	Host           string `value:"${host:=127.0.0.1}"`    // IP
	Port           int    `value:"${port:=6379}"`         // 端口号
	Username       string `value:"${username:=}"`         // 用户名
	Password       string `value:"${password:=}"`         // 密码
	Database       int    `value:"${database:=0}"`        // DB 序号
	Ping           bool   `value:"${ping:=true}"`         // 是否 PING 探测
	ConnectTimeout int    `value:"${connect-timeout:=0}"` // 连接超时,毫秒
	ReadTimeout    int    `value:"${read-timeout:=0}"`    // 读取超时,毫秒
	WriteTimeout   int    `value:"${write-timeout:=0}"`   // 写入超时,毫秒
	IdleTimeout    int    `value:"${idle-timeout:=0}"`    // 空闲连接超时,毫秒
}

type ConnPool

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

type HashOperations

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

func NewHashOperations

func NewHashOperations(c *Client) *HashOperations

func (*HashOperations) HDel

func (c *HashOperations) 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 (*HashOperations) HExists

func (c *HashOperations) 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 (*HashOperations) HGet

func (c *HashOperations) 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 (*HashOperations) HGetAll

func (c *HashOperations) 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 (*HashOperations) HIncrBy

func (c *HashOperations) 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 (*HashOperations) HIncrByFloat

func (c *HashOperations) 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 (*HashOperations) HKeys

func (c *HashOperations) 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 (*HashOperations) HLen

func (c *HashOperations) 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 (*HashOperations) HMGet

func (c *HashOperations) 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 (*HashOperations) HSet

func (c *HashOperations) 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 (*HashOperations) HSetNX

func (c *HashOperations) 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 (*HashOperations) HStrLen

func (c *HashOperations) 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 (*HashOperations) HVals

func (c *HashOperations) 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.

type KeyOperations

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

func NewKeyOperations

func NewKeyOperations(c *Client) *KeyOperations

func (*KeyOperations) Del

func (c *KeyOperations) 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 (*KeyOperations) Dump

func (c *KeyOperations) 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 (*KeyOperations) Exists

func (c *KeyOperations) 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 (*KeyOperations) Expire

func (c *KeyOperations) 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 (*KeyOperations) ExpireAt

func (c *KeyOperations) 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 (*KeyOperations) Keys

func (c *KeyOperations) 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 (*KeyOperations) PExpire

func (c *KeyOperations) 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 (*KeyOperations) PExpireAt

func (c *KeyOperations) 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 (*KeyOperations) PTTL

func (c *KeyOperations) 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 (*KeyOperations) Persist

func (c *KeyOperations) 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 (*KeyOperations) RandomKey

func (c *KeyOperations) 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 (*KeyOperations) Rename

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

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

func (*KeyOperations) RenameNX

func (c *KeyOperations) 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 (*KeyOperations) TTL

func (c *KeyOperations) 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 (*KeyOperations) Touch

func (c *KeyOperations) 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 (*KeyOperations) Type

func (c *KeyOperations) 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.

type ListOperations

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

func NewListOperations

func NewListOperations(c *Client) *ListOperations

func (*ListOperations) LIndex

func (c *ListOperations) 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 (*ListOperations) LInsertAfter

func (c *ListOperations) 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 (*ListOperations) LInsertBefore

func (c *ListOperations) 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 (*ListOperations) LLen

func (c *ListOperations) 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 (*ListOperations) LMove

func (c *ListOperations) 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 (*ListOperations) LPop

func (c *ListOperations) 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 (*ListOperations) LPopN

func (c *ListOperations) 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 (*ListOperations) LPos

func (c *ListOperations) 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 (*ListOperations) LPosN

func (c *ListOperations) 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 (*ListOperations) LPush

func (c *ListOperations) 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 (*ListOperations) LPushX

func (c *ListOperations) 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 (*ListOperations) LRange

func (c *ListOperations) 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 (*ListOperations) LRem

func (c *ListOperations) 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 (*ListOperations) LSet

func (c *ListOperations) 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 (*ListOperations) LTrim

func (c *ListOperations) 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 (*ListOperations) RPop

func (c *ListOperations) 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 (*ListOperations) RPopLPush

func (c *ListOperations) 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 (*ListOperations) RPopN

func (c *ListOperations) 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 (*ListOperations) RPush

func (c *ListOperations) 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 (*ListOperations) RPushX

func (c *ListOperations) 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.

type MockConnPool

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

MockConnPool is a mock of ConnPool interface.

func NewMockConnPool

func NewMockConnPool(ctrl *gomock.Controller) *MockConnPool

NewMockConnPool creates a new mock instance.

func (*MockConnPool) EXPECT

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

func (*MockConnPool) Exec

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

Exec mocks base method.

type MockConnPoolMockRecorder

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

MockConnPoolMockRecorder is the mock recorder for MockConnPool.

func (*MockConnPoolMockRecorder) Exec

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

Exec indicates an expected call of Exec.

type ServerOperations

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

func NewServerOperations

func NewServerOperations(c *Client) *ServerOperations

func (*ServerOperations) FlushAll

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

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

type SetOperations

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

func NewSetOperations

func NewSetOperations(c *Client) *SetOperations

func (*SetOperations) SAdd

func (c *SetOperations) 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 (*SetOperations) SCard

func (c *SetOperations) 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 (*SetOperations) SDiff

func (c *SetOperations) 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 (*SetOperations) SDiffStore

func (c *SetOperations) 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 (*SetOperations) SInter

func (c *SetOperations) 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 (*SetOperations) SInterStore

func (c *SetOperations) 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 (*SetOperations) SIsMember

func (c *SetOperations) 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 (*SetOperations) SMIsMember

func (c *SetOperations) 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 (*SetOperations) SMembers

func (c *SetOperations) 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 (*SetOperations) SMove

func (c *SetOperations) 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 (*SetOperations) SPop

func (c *SetOperations) 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 (*SetOperations) SPopN

func (c *SetOperations) 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 (*SetOperations) SRandMember

func (c *SetOperations) 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 (*SetOperations) SRandMemberN

func (c *SetOperations) 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 (*SetOperations) SRem

func (c *SetOperations) 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 (*SetOperations) SUnion

func (c *SetOperations) 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 (*SetOperations) SUnionStore

func (c *SetOperations) 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.

type StringOperations

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

func NewStringOperations

func NewStringOperations(c *Client) *StringOperations

func (*StringOperations) Append

func (c *StringOperations) 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 (*StringOperations) Decr

func (c *StringOperations) 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 (*StringOperations) DecrBy

func (c *StringOperations) 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 (*StringOperations) Get

func (c *StringOperations) 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 (*StringOperations) GetDel

func (c *StringOperations) 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 (*StringOperations) GetEx

func (c *StringOperations) 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 (*StringOperations) GetRange

func (c *StringOperations) 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 (*StringOperations) GetSet

func (c *StringOperations) 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 (*StringOperations) Incr

func (c *StringOperations) 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 (*StringOperations) IncrBy

func (c *StringOperations) 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 (*StringOperations) IncrByFloat

func (c *StringOperations) 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 (*StringOperations) MGet

func (c *StringOperations) 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 (*StringOperations) MSet

func (c *StringOperations) 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 (*StringOperations) MSetNX

func (c *StringOperations) 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 (*StringOperations) PSetEX

func (c *StringOperations) 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 (*StringOperations) Set

func (c *StringOperations) 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 (*StringOperations) SetEX

func (c *StringOperations) 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 (*StringOperations) SetNX

func (c *StringOperations) 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 (*StringOperations) SetRange

func (c *StringOperations) 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 (*StringOperations) StrLen

func (c *StringOperations) 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.

type ZItem

type ZItem struct {
	Member interface{}
	Score  float64
}

type ZSetOperations

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

func NewZSetOperations

func NewZSetOperations(c *Client) *ZSetOperations

func (*ZSetOperations) ZAdd

func (c *ZSetOperations) 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 (*ZSetOperations) ZCard

func (c *ZSetOperations) 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 (*ZSetOperations) ZCount

func (c *ZSetOperations) 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 (*ZSetOperations) ZDiff

func (c *ZSetOperations) 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 (*ZSetOperations) ZDiffWithScores

func (c *ZSetOperations) 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 (*ZSetOperations) ZIncrBy

func (c *ZSetOperations) 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 (*ZSetOperations) ZInter

func (c *ZSetOperations) 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 (*ZSetOperations) ZInterWithScores

func (c *ZSetOperations) 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 (*ZSetOperations) ZLexCount

func (c *ZSetOperations) 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 (*ZSetOperations) ZMScore

func (c *ZSetOperations) 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 (*ZSetOperations) ZPopMax

func (c *ZSetOperations) 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 (*ZSetOperations) ZPopMaxN

func (c *ZSetOperations) 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 (*ZSetOperations) ZPopMin

func (c *ZSetOperations) 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 (*ZSetOperations) ZPopMinN

func (c *ZSetOperations) 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 (*ZSetOperations) ZRandMember

func (c *ZSetOperations) 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 (*ZSetOperations) ZRandMemberN

func (c *ZSetOperations) 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 (*ZSetOperations) ZRandMemberWithScores

func (c *ZSetOperations) 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 (*ZSetOperations) ZRange

func (c *ZSetOperations) 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 (*ZSetOperations) ZRangeByLex

func (c *ZSetOperations) 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 (*ZSetOperations) ZRangeByScore

func (c *ZSetOperations) 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 (*ZSetOperations) ZRangeWithScores

func (c *ZSetOperations) 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 (*ZSetOperations) ZRank

func (c *ZSetOperations) 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 (*ZSetOperations) ZRem

func (c *ZSetOperations) 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 (*ZSetOperations) ZRemRangeByLex

func (c *ZSetOperations) 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 (*ZSetOperations) ZRemRangeByRank

func (c *ZSetOperations) 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 (*ZSetOperations) ZRemRangeByScore

func (c *ZSetOperations) 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 (*ZSetOperations) ZRevRange

func (c *ZSetOperations) 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 (*ZSetOperations) ZRevRangeByLex

func (c *ZSetOperations) 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 (*ZSetOperations) ZRevRangeByScore

func (c *ZSetOperations) 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 (*ZSetOperations) ZRevRangeWithScores

func (c *ZSetOperations) 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 (*ZSetOperations) ZRevRank

func (c *ZSetOperations) 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 (*ZSetOperations) ZScore

func (c *ZSetOperations) 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 (*ZSetOperations) ZUnion

func (c *ZSetOperations) 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 (*ZSetOperations) ZUnionStore

func (c *ZSetOperations) 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 (*ZSetOperations) ZUnionWithScores

func (c *ZSetOperations) 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.

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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