red

package module
v0.0.0-...-5546168 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

README

red

Redis client for golang

Documentation

Index

Constants

KeepTTL sets the SET command's KEEPTTL flag in redis 6

View Source
const MaxDBIndex = 16

MaxDBIndex is the max db index allowed by redis.

View Source
const StatusOK = resp.SimpleString("OK")

StatusOK is the default success status

View Source
const StatusQueued = resp.SimpleString("QUEUED")

StatusQueued is the status of a command in a MULTI/EXEC transaction

Variables

View Source
var ErrDiscarded = errors.New("MULTI/EXEC Transaction discarded")

ErrDiscarded is the error of a reply if it's part of a transaction that got discarded

View Source
var (
	// ErrNoReplies is returned when no more replies are expected on Scan
	ErrNoReplies = errors.New("No more replies")
)
View Source
var ErrReplyPending = errors.New("Reply pending")

ErrReplyPending is the error of a reply until a `Client.Sync` is called

Functions

func DBIndexValid

func DBIndexValid(index int) bool

DBIndexValid checks if a DBIndex is valid

func ReleaseBatch

func ReleaseBatch(b *Batch)

ReleaseBatch releases a Batch to a package-wide pool

Types

type Aggregate

type Aggregate int

Aggregate is an aggregate method

const (
	AggregateSum Aggregate
	AggregateMin
	AggregateMax
)

Aggregate methods

func (Aggregate) String

func (a Aggregate) String() string

type Arg

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

Arg is a command argument

func Bool

func Bool(b bool) Arg

Bool creates a boolean argument.

func Float32

func Float32(f float32) Arg

Float32 creates a float argument.

func Float64

func Float64(f float64) Arg

Float64 creates a float argument.

func Int

func Int(n int) Arg

Int creates an int argument.

func Int16

func Int16(n int16) Arg

Int16 creates an int16 argument.

func Int32

func Int32(n int32) Arg

Int32 creates an int32 argument.

func Int64

func Int64(n int64) Arg

Int64 creates an int64 argument.

func Int8

func Int8(n int8) Arg

Int8 creates an int8 argument.

func Key

func Key(s string) Arg

Key creates a string argument to be used as a key.

func Lex

func Lex(lex string, inclusive bool) Arg

Lex creates a lex range argument (ie '[foo', '(foo')

func MaxLex

func MaxLex() Arg

MaxLex creates a max infinity lex range arument

func MaxScore

func MaxScore() Arg

MaxScore creates a max infinity score range argument

func Milliseconds

func Milliseconds(d time.Duration) Arg

Milliseconds creates an argument converting d to milliseconds

func MinLex

func MinLex() Arg

MinLex creates a minus infinity lex range arument

func MinScore

func MinScore() Arg

MinScore creates a minus infinity score range argument

func QuickArgs

func QuickArgs(key string, args ...string) []Arg

QuickArgs makes a slice of args where the first is a key and the reset strings

func Score

func Score(score float64, inclusive bool) Arg

Score creates an score range argument (ie '42.0', '(42.0')

func Seconds

func Seconds(d time.Duration) Arg

Seconds creates an argument converting d to seconds

func String

func String(s string) Arg

String createa a string argument.

func Uint

func Uint(n uint) Arg

Uint creates an unsigned int argument.

func Uint16

func Uint16(n uint16) Arg

Uint16 creates a uint16 argument.

func Uint32

func Uint32(n uint32) Arg

Uint32 creates a uint32 argument.

func Uint64

func Uint64(n uint64) Arg

Uint64 creates a uint64 argument.

func Uint8

func Uint8(n uint8) Arg

Uint8 creates a uint8 argument.

func UnixMilliseconds

func UnixMilliseconds(tm time.Time) Arg

UnixMilliseconds creates an argument converting tm to unix ms timestamp

func UnixSeconds

func UnixSeconds(tm time.Time) Arg

UnixSeconds creates an argument converting tm to unix timestamp

func (Arg) Equal

func (a Arg) Equal(other Arg) bool

Equal checks if two args a are equal

func (Arg) IsZero

func (a Arg) IsZero() bool

IsZero checks if an arg is the zero value

func (*Arg) Value

func (a *Arg) Value() interface{}

Value returns the go value of an arg

type ArgBuilder

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

ArgBuilder is an argument builder

func (*ArgBuilder) Append

func (a *ArgBuilder) Append(args ...Arg)

Append adds multiple arguments

func (*ArgBuilder) Arg

func (a *ArgBuilder) Arg(arg Arg)

Arg adds an argument

func (*ArgBuilder) Args

func (a *ArgBuilder) Args() (args []Arg)

Args returns the current args in a builder

func (*ArgBuilder) Clear

func (a *ArgBuilder) Clear()

Clear resets args to empty and releases strings for GC

func (*ArgBuilder) Field

func (a *ArgBuilder) Field(name string, value Arg)

Field adds a field-value pair

func (*ArgBuilder) Flag

func (a *ArgBuilder) Flag(flag string, ok bool)

Flag adds an optional flag if ok is true

func (*ArgBuilder) Float

func (a *ArgBuilder) Float(f float64)

Float adds a float argument

func (*ArgBuilder) Int

func (a *ArgBuilder) Int(n int64)

Int adds an integer argument

func (*ArgBuilder) KV

func (a *ArgBuilder) KV(key string, arg Arg)

KV adds a key-value pair

func (*ArgBuilder) Key

func (a *ArgBuilder) Key(key string)

Key adds a key argument

func (*ArgBuilder) Keys

func (a *ArgBuilder) Keys(keys ...string)

Keys adds multiple key arguments

func (*ArgBuilder) KeysUnique

func (a *ArgBuilder) KeysUnique(key string, keys ...string)

func (*ArgBuilder) Len

func (a *ArgBuilder) Len() int

Len returns the number of arguments

func (*ArgBuilder) Milliseconds

func (a *ArgBuilder) Milliseconds(d time.Duration)

Milliseconds adds a duration in ms

func (*ArgBuilder) Option

func (a *ArgBuilder) Option(option, value string)

Option adds an optional argument with a value

func (*ArgBuilder) Reset

func (a *ArgBuilder) Reset()

Reset resets args to empty

func (*ArgBuilder) Score

func (a *ArgBuilder) Score(score float64, include bool)

Score adds a score range argument

func (*ArgBuilder) Seconds

func (a *ArgBuilder) Seconds(d time.Duration)

Seconds adds a duration in sec

func (*ArgBuilder) String

func (a *ArgBuilder) String(str string)

String adds a string argument

func (*ArgBuilder) Strings

func (a *ArgBuilder) Strings(args ...string)

Strings adds multiple string arguments

func (*ArgBuilder) Swap

func (a *ArgBuilder) Swap(args []Arg) []Arg

Swap swaps args in a builder

func (*ArgBuilder) Unique

func (a *ArgBuilder) Unique(arg string, args ...string)

Unique adds multiple string arguments omitting the first argument of args if it's equal to arg

type AssertNonNullArray

type AssertNonNullArray struct{}

AssertNonNullArray checks if a RESP value is a non null array.

func (*AssertNonNullArray) UnmarshalRESP

func (*AssertNonNullArray) UnmarshalRESP(v resp.Value) error

UnmarshalRESP implements resp.Unmarshaler interface

type AssertOK

type AssertOK struct {
	Mode Mode
}

AssertOK is a convenience target for `conn.Scan` to check an `OK` reply

func (*AssertOK) UnmarshalRESP

func (ok *AssertOK) UnmarshalRESP(v resp.Value) error

UnmarshalRESP implements the resp.Unmarshal interface

type Batch

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

Batch is a batch of redis commands bound to replies

func AcquireBatch

func AcquireBatch() *Batch

AcquireBatch gets an empty Batch from a package-wide pool

func (*Batch) Append

func (b *Batch) Append(key, value string) *ReplyBulkString

Append appends a string to a value of a key

func (*Batch) Decr

func (b *Batch) Decr(key string) *ReplyInteger

Decr decrements key by 1

func (*Batch) DecrBy

func (b *Batch) DecrBy(key string, d int64) *ReplyInteger

DecrBy decrements key by n

func (*Batch) Del

func (b *Batch) Del(key string, keys ...string) *ReplyInteger

Del adds a DEL command to the pipeline

func (*Batch) Do

func (b *Batch) Do(cmd string, args ...Arg) *ReplyAny

func (*Batch) Dump

func (b *Batch) Dump(key string) *ReplyBulkString

Dump adds a DUMP command

func (*Batch) Exists

func (b *Batch) Exists(keys ...string) *ReplyInteger

Exists is redis EXISTS command

func (*Batch) Expire

func (b *Batch) Expire(key string, ttl time.Duration) *ReplyInteger

Expire is redis EXPIRE command

func (*Batch) ExpireAt

func (b *Batch) ExpireAt(key string, tm time.Time) *ReplyInteger

ExpireAt is redis EXPIREAT command

func (*Batch) FlushDB

func (b *Batch) FlushDB(async bool) *ReplyOK

FlushDB writes a redis FLUSHDB command

func (*Batch) Get

func (b *Batch) Get(key string) *ReplyBulkString

Get returns the string value of a key

func (*Batch) GetRange

func (b *Batch) GetRange(key string, start, end int64) *ReplyBulkString

GetRange gets a part of a string

func (*Batch) GetSet

func (b *Batch) GetSet(key, value string) *ReplyBulkString

GetSet atomicaly replaces a value returning the old value

func (*Batch) HDel

func (b *Batch) HDel(key, field string, fields ...string) *ReplyInteger

HDel deletes fields from a map

func (*Batch) HExists

func (b *Batch) HExists(key, field string) *ReplyBool

HExists checks if a field exists in a map

func (*Batch) HGet

func (b *Batch) HGet(key, field string) *ReplyBulkString

HGet gets a map field value

func (*Batch) HGetAll

func (b *Batch) HGetAll(key string) *ReplyBulkStringArray

HGetAll gets all field/value pairs in a map

func (*Batch) HIncrBy

func (b *Batch) HIncrBy(key, field string, incr int64) *ReplyInteger

HIncrBy increments a field in a map

func (*Batch) HIncrByFloat

func (b *Batch) HIncrByFloat(key, field string, incr float64) *ReplyFloat

HIncrByFloat increments a field in a map by a float value

func (*Batch) HKeys

func (b *Batch) HKeys(key string) *ReplyBulkStringArray

HKeys gets all field keys in a map

func (*Batch) HLen

func (b *Batch) HLen(key string) *ReplyInteger

HLen returns the number of fields in a map

func (*Batch) HMGet

func (b *Batch) HMGet(key, field string, fields ...string) *ReplyBulkStringArray

HMGet returns the values associated with the specified fields in the hash stored at key. For convenience in cases where the fields are already an array the first field is compared to `field`

func (*Batch) HSet

func (b *Batch) HSet(key, field, value string, entries ...string) *ReplyInteger

HSet adds an HSet command to the pipeline

func (*Batch) HSetArg

func (b *Batch) HSetArg(key string, field string, value Arg, entries ...HArg) *ReplyInteger

HSetArg adds an HSet command to the pipeline using Arg

func (*Batch) HSetNX

func (b *Batch) HSetNX(key, field, value string) *ReplyBool

HSetNX sets the value of a new field in a map

func (*Batch) HSetNXArg

func (b *Batch) HSetNXArg(key, field string, value Arg) *ReplyBool

HSetNXArg sets the value of a new field in a map using Arg

func (*Batch) HStrLen

func (b *Batch) HStrLen(key, field string) *ReplyInteger

HStrLen returns the string length of the value of a field in a map

func (*Batch) HVals

func (b *Batch) HVals(key string) *ReplyBulkStringArray

HVals returns the values of all fields in a map

func (*Batch) Incr

func (b *Batch) Incr(key string) *ReplyInteger

Incr increments key by 1

func (*Batch) IncrBy

func (b *Batch) IncrBy(key string, n int64) *ReplyInteger

IncrBy incremments the value at a key by an integer amount

func (*Batch) IncrByFloat

func (b *Batch) IncrByFloat(key string, incr float64) *ReplyFloat

IncrByFloat incremments the value at a key by a float amount

func (*Batch) Keys

func (b *Batch) Keys(pattern string) *ReplyBulkStringArray

Keys returns all keys matching a pattern

func (*Batch) LIndex

func (c *Batch) LIndex(key string, index int64) *ReplyInteger

LIndex returns the element at index index in the list stored at key.

func (*Batch) LInsertAfter

func (c *Batch) LInsertAfter(key string, pivot int64, value Arg) *ReplyInteger

LInsertAfter inserts element in the list stored at key after the reference value pivot. LINSERT key AFTER pivot element

func (*Batch) LInsertBefore

func (c *Batch) LInsertBefore(key string, pivot int64, value Arg) *ReplyInteger

LInsertBefore inserts element in the list stored at key before the reference value pivot. LINSERT key BEFORE pivot element

func (*Batch) LLen

func (c *Batch) LLen(key string) *ReplyInteger

LLen returns the length of the list stored at key.

func (*Batch) LPop

func (c *Batch) LPop(key string) *ReplyBulkString

LPop removes and returns the first element of the list stored at key.

func (*Batch) LPush

func (c *Batch) LPush(key string, values ...Arg) *ReplyInteger

LPush inserts specified values at the head of the list stored at key.

func (*Batch) LPushX

func (c *Batch) LPushX(key string, values ...Arg) *ReplyInteger

LPushX inserts specified values at the head of the list stored at key, only if key already exists and holds a list.

func (*Batch) LRange

func (c *Batch) LRange(key string, start, stop int64) *ReplyBulkStringArray

LRange returns the specified elements of the list stored at key. LRANGE key start stop

func (*Batch) LRem

func (c *Batch) LRem(key string, count int64, element Arg) *ReplyInteger

LRem removes the first count occurrences of elements equal to element from the list stored at key.

func (*Batch) LSet

func (c *Batch) LSet(key string, index int64, element Arg) *ReplyOK

LSet sets list element at index to element.

func (*Batch) LTrim

func (c *Batch) LTrim(key string, start, stop int64) *ReplyInteger

LTrim trims an existing list so that it will contain only the specified range of elements specified.

func (*Batch) MGet

func (b *Batch) MGet(key string, keys ...string) *ReplyBulkStringArray

MGet gets multiple key values

func (*Batch) MSet

func (b *Batch) MSet(values ...string) *ReplyOK

MSet sets multiple keys

func (*Batch) MSetArg

func (b *Batch) MSetArg(values map[string]Arg) *ReplyOK

MSetArg sets multiple keys

func (*Batch) MSetNX

func (b *Batch) MSetNX(values ...string) *ReplyBool

MSetNX sets multiple keys if they do not exist

func (*Batch) Migrate

func (b *Batch) Migrate(m Migrate) *ReplyOK

Migrate moves data across servers

func (*Batch) Move

func (b *Batch) Move(key string, db int) *ReplyInteger

Move moves a key to a different DB index

func (*Batch) Multi

func (b *Batch) Multi(tx *Tx) *ReplyTX

Multi queues a MULTI/EXEC transaction

func (*Batch) ObjectEncoding

func (b *Batch) ObjectEncoding(key string) *ReplyBulkString

ObjectEncoding is the redis' OBJECT ENCODING command

func (*Batch) ObjectFreq

func (b *Batch) ObjectFreq(key string) *ReplyInteger

ObjectFreq is the redis' OBJECT FREQ command

func (*Batch) ObjectHelp

func (b *Batch) ObjectHelp(key string) *ReplyBulkString

ObjectHelp is the redis' OBJECT HELP command

func (*Batch) ObjectIdleTime

func (b *Batch) ObjectIdleTime(key string) *ReplyInteger

ObjectIdleTime is the redis' OBJECT IDLETIME command

func (*Batch) ObjectRefCount

func (b *Batch) ObjectRefCount(key string) *ReplyInteger

ObjectRefCount is the redis' OBJECT REFCOUNT command

func (*Batch) PExpire

func (b *Batch) PExpire(key string, ttl time.Duration) *ReplyInteger

PExpire adds a TTL to a key in milliseconds

func (*Batch) PExpireAt

func (b *Batch) PExpireAt(key string, tm time.Time) *ReplyInteger

PExpireAt is redis PEXPIREAT command

func (*Batch) PTTL

func (b *Batch) PTTL(key string) *ReplyInteger

PTTL gets the TTL of a key in milliseconds

func (*Batch) Persist

func (b *Batch) Persist(key string) *ReplyInteger

Persist removes any TTL from a key

func (Batch) PubSubChannels

func (b Batch) PubSubChannels(pattern string) *ReplyBulkStringArray

PubSubChannels lists all active channels. PUBSUB CHANNELS [pattern] If no pattern is specified all channels are listed, otherwise if pattern is specified only channels matching the specified glob-style pattern are listed.

func (*Batch) PubSubNumPat

func (b *Batch) PubSubNumPat() *ReplyInteger

PubSubNumPat returns the number of subscriptions to patterns (that are performed using the PSUBSCRIBE command). Note that this is not just the count of clients subscribed to patterns but the total number of patterns all the clients are subscribed to. PUBSUB NUMPAT

func (*Batch) PubSubNumSub

func (b *Batch) PubSubNumSub(channels ...string) *ReplyInteger

PubSubNumSub returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels. PUBSUB NUMSUB [channel-1 ... channel-N]

func (*Batch) Publish

func (b *Batch) Publish(channel, msg string) *ReplyInteger

Publish publishes a message on a channel

func (*Batch) RPop

func (c *Batch) RPop(key string) *ReplyBulkString

RPop removes and returns the last element of the list stored at key.

func (*Batch) RPopLPush

func (c *Batch) RPopLPush(src, dest string, timeout time.Duration) *ReplyBulkString

RPopLPush atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.

func (*Batch) RPush

func (c *Batch) RPush(key string, elements ...Arg) *ReplyInteger

RPush inserts specified values at the tail of the list stored at key.

func (*Batch) RPushX

func (c *Batch) RPushX(key string, elements ...Arg) *ReplyInteger

RPushX Inserts specified values at the tail of the list stored at key, only if key already exists and holds a list.

func (*Batch) RandomKey

func (b *Batch) RandomKey() *ReplyBulkString

RandomKey returns a random key

func (*Batch) Rename

func (b *Batch) Rename(key, newkey string) *ReplyOK

Rename renames a key

func (*Batch) RenameNX

func (b *Batch) RenameNX(key, newkey string) *ReplyOK

RenameNX renames a key if the new name does not exist

func (*Batch) Reset

func (b *Batch) Reset()

Reset clears all pending commands

func (*Batch) Restore

func (b *Batch) Restore(r Restore) *ReplyOK

Restore restores a key value from a string

func (*Batch) Set

func (b *Batch) Set(key, value string, ttl time.Duration) *ReplyOK

Set sets a key to value

func (*Batch) SetEX

func (b *Batch) SetEX(key, value string, ttl time.Duration) *ReplyOK

SetEX sets a key with a ttl

func (*Batch) SetNX

func (b *Batch) SetNX(key, value string, ttl time.Duration) *ReplyOK

SetNX sets a new key value

func (*Batch) SetRange

func (b *Batch) SetRange(key string, offset int64, value string) *ReplyBulkString

SetRange sets a part of a string

func (*Batch) SetXX

func (b *Batch) SetXX(key, value string, ttl time.Duration) *ReplyOK

SetXX resets a key value if it exists

func (*Batch) Sort

func (b *Batch) Sort(key string, sort Sort) *ReplyBulkStringArray

Sort sorts a key's values

func (*Batch) SortStore

func (b *Batch) SortStore(dest, key string, sort Sort) *ReplyInteger

SortStore sorts a `key`'s value storing the result in `dest`

func (*Batch) StrLen

func (b *Batch) StrLen(key string) *ReplyBulkString

StrLen return the length of a string value

func (*Batch) TTL

func (b *Batch) TTL(key string) *ReplyInteger

TTL returns the remaining lifetime of a key in seconds

func (*Batch) Touch

func (b *Batch) Touch(keys ...string) *ReplyInteger

Touch alters the last access time of a key(s).

func (*Batch) Type

func (b *Batch) Type(key string) *ReplySimpleString

Type returns the type of the value of a key

func (b *Batch) Unlink(keys ...string) *ReplyInteger

Unlink drops keys

func (*Batch) Unwatch

func (b *Batch) Unwatch() *ReplyOK

Unwatch adds an UNWATCH command to the pipeline

func (*Batch) Wait

func (b *Batch) Wait(numReplicas int, timeout time.Duration) *ReplyInteger

Wait blocks until a number of replicas have stored the data or timeout occured

func (*Batch) Watch

func (b *Batch) Watch(keys ...string) *ReplyOK

Watch adds a WATCH command to the pipeline

func (*Batch) XAck

func (b *Batch) XAck(key, group string, id string, ids ...string) *ReplyInteger

XAck removes one or multiple messages from the pending entries list (PEL) of a stream consumer group. XACK key group ID [ID ...]

func (*Batch) XAdd

func (b *Batch) XAdd(key string, maxLen int64, id string, fields ...HArg) *ReplyBulkString

XAdd appends the specified stream entry to the stream at the specified key.

XADD key ID field value [field value ...]

If the key does not exist, as a side effect of running this command, the key is created with a stream value.

func (*Batch) XDel

func (b *Batch) XDel(key string, ids ...string) *ReplyInteger

XDel deletes entries from a stream

func (*Batch) XGroupCreate

func (b *Batch) XGroupCreate(key, group, id string, makeStream bool) *ReplyOK

XGroupCreate creates a new consumer group associated with a stream. XGROUP [CREATE key groupname id-or-$]

func (*Batch) XGroupDelConsumer

func (b *Batch) XGroupDelConsumer(key, group, consumer string) *ReplyInteger

XGroupDelConsumer removes a specific consumer from a consumer group

func (*Batch) XGroupDestroy

func (b *Batch) XGroupDestroy(key, group string) *ReplyInteger

XGroupDestroy destroys a consumer group

func (*Batch) XGroupSetID

func (b *Batch) XGroupSetID(key, group, id string) *ReplyOK

XGroupSetID sets the consumer group last delivered ID to something else. XGROUP [SETID key groupname id-or-$]

func (*Batch) XInfoConsumers

func (b *Batch) XInfoConsumers(key, group string) *ReplyXInfoConsumers

XInfoConsumers returns the list of every consumer in a specific consumer group

func (*Batch) XInfoGroups

func (b *Batch) XInfoGroups(key string) *ReplyXInfoGroups

XInfoGroups returns all the consumer groups associated with the stream.

func (*Batch) XInfoHelp

func (b *Batch) XInfoHelp() *ReplyBulkStringArray

XInfoHelp gets help for XINFO command

func (*Batch) XInfoStream

func (b *Batch) XInfoStream(key string) *ReplyXInfoStream

XInfoStream returns general information about the stream stored at the specified key.

func (*Batch) XLen

func (b *Batch) XLen(key string) *ReplyInteger

XLen returns the number of entries inside a stream.

func (*Batch) XPending

func (b *Batch) XPending(key, group string) *ReplyXPendingSummary

func (*Batch) XPendingConsumer

func (b *Batch) XPendingConsumer(args XPending) *ReplyXPending

func (*Batch) XPendingGroup

func (b *Batch) XPendingGroup(args XPending) *ReplyXPending

func (*Batch) XRange

func (b *Batch) XRange(key, group, start, end string, count int64) *ReplyXRange

Command implements Commander interface

func (*Batch) XRevRange

func (b *Batch) XRevRange(key, group, end, start string, count int64) *ReplyXRange

func (*Batch) ZAdd

func (b *Batch) ZAdd(key string, mode Mode, members ...ZEntry) *ReplyInteger

ZAdd adds or modifies the a member of a sorted set

func (*Batch) ZAddIncr

func (b *Batch) ZAddIncr(key string, mode Mode, member string, d float64) *ReplyFloat

ZAddIncr increments the score of a sorted set member by d

func (*Batch) ZCard

func (b *Batch) ZCard(key string) *ReplyInteger

ZCard returns the cardinality of a sorted set

func (*Batch) ZCount

func (b *Batch) ZCount(key string, min, max Arg) *ReplyInteger

ZCount returns the number of elements in the sorted set at key with a score between min and max.

func (*Batch) ZIncrBy

func (b *Batch) ZIncrBy(key string, incr float64, member string) *ReplyFloat

ZIncrBy increments the score of member in the sorted set stored at key by increment.

func (*Batch) ZInterStore

func (b *Batch) ZInterStore(args ZStore) *ReplyInteger

ZInterStore computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in destination.

func (*Batch) ZLexCount

func (b *Batch) ZLexCount(key string, min, max Arg) *ReplyInteger

ZLexCount returns the number of elements in the sorted set at key with a value between min and max.

func (*Batch) ZPopMax

func (b *Batch) ZPopMax(key string, count int64) *ReplyZRange

ZPopMax removes and returns up to count members with the highest scores in the sorted set stored at key.

func (*Batch) ZPopMin

func (b *Batch) ZPopMin(key string, count int64) *ReplyZRange

ZPopMin removes and returns up to count members with the lowest scores in the sorted set stored at key.

func (*Batch) ZRange

func (b *Batch) ZRange(key string, start, stop int64) *ReplyBulkStringArray

ZRange returns the specified range of elements in the sorted set stored at key.

func (*Batch) ZRangeByLex

func (b *Batch) ZRangeByLex(key string, min, max Arg, offset, count int64) *ReplyBulkStringArray

ZRangeByLex when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returnWhen all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.s all the elements in the sorted set at key with a value between min and max.

func (*Batch) ZRangeByScore

func (b *Batch) ZRangeByScore(key string, min, max Arg, offset, count int64) *ReplyBulkStringArray

ZRangeByScore returns all the elements in the sorted set at key with a score between min and max

func (*Batch) ZRangeByScoreWithScores

func (b *Batch) ZRangeByScoreWithScores(key string, min, max Arg, offset, count int64) *ReplyZRange

ZRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max

func (*Batch) ZRangeWithScores

func (b *Batch) ZRangeWithScores(key string, start, stop int64) *ReplyZRange

ZRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*Batch) ZRank

func (b *Batch) ZRank(key, member string) *ReplyInteger

ZRank gets the rank of a member of a sorted set ordered from low to high

func (*Batch) ZRem

func (b *Batch) ZRem(key string, members ...string) *ReplyInteger

ZRem removes member(s) from a sorted set

func (*Batch) ZRemRangeByLex

func (b *Batch) ZRemRangeByLex(key string, min, max Arg) *ReplyInteger

ZRemRangeByLex removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.

func (*Batch) ZRemRangeByRank

func (b *Batch) ZRemRangeByRank(key string, start, stop int64) *ReplyInteger

ZRemRangeByRank removes all elements in the sorted set stored at key with rank between start and stop.

func (*Batch) ZRemRangeByScore

func (b *Batch) ZRemRangeByScore(key string, min, max Arg) *ReplyInteger

ZRemRangeByScore removes all elements in the sorted set stored at key with a score between min and max (inclusive).

func (*Batch) ZRevRange

func (b *Batch) ZRevRange(key string, start, stop int64) *ReplyBulkStringArray

ZRevRange returns the specified range of elements in the sorted set stored at key.

func (*Batch) ZRevRangeByLex

func (b *Batch) ZRevRangeByLex(key string, max, min Arg, offset, count int64) *ReplyBulkStringArray

ZRevRangeByLex when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returnWhen all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.s all the elements in the sorted set at key with a value between min and max.

func (*Batch) ZRevRangeByScore

func (b *Batch) ZRevRangeByScore(key string, max, min Arg, offset, count int64) *ReplyBulkStringArray

ZRevRangeByScore returns all the elements in the sorted set at key with a score between min and max

func (*Batch) ZRevRangeByScoreWithScores

func (b *Batch) ZRevRangeByScoreWithScores(key string, max, min Arg, offset, count int64) *ReplyZRange

ZRevRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max

func (*Batch) ZRevRangeWithScores

func (b *Batch) ZRevRangeWithScores(key string, start, stop int64) *ReplyZRange

ZRevRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*Batch) ZRevRank

func (b *Batch) ZRevRank(key, member string) *ReplyInteger

ZRevRank gets the rank of a member of a sorted set ordered from high to low

func (*Batch) ZScore

func (b *Batch) ZScore(key, member string) *ReplyFloat

ZScore returns the score of a member

func (*Batch) ZUnionStore

func (b *Batch) ZUnionStore(args ZStore) *ReplyInteger

ZUnionStore computes the union of numkeys sorted sets given by the specified keys, and stores the result in destination.

type CommandBuilder

type CommandBuilder interface {
	BuildCommand(args *ArgBuilder) string
}

CommandBuilder builds a redis command

type CommandWriter

type CommandWriter interface {
	WriteCommand(name string, args ...Arg) error
}

CommandWriter writes a redis command

type Conn

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

Conn is a redis client connection

func Dial

func Dial(addr string, options *ConnOptions) (*Conn, error)

Dial opens a connection to a redis server

func WrapConn

func WrapConn(conn net.Conn, options *ConnOptions) (*Conn, error)

WrapConn wraps a net.Conn in a redis connection

func (*Conn) Auth

func (conn *Conn) Auth(password string) error

Auth authenticates a connection

func (*Conn) BLPop

func (c *Conn) BLPop(timeout time.Duration, key string, keys ...string) (pop Pop, err error)

BLPop is the blocking variant of LPop

func (*Conn) BRPop

func (c *Conn) BRPop(timeout time.Duration, key string, keys ...string) (pop Pop, err error)

BRPop is the blocking variant of RPop

func (*Conn) BRPopLPush

func (c *Conn) BRPopLPush(src, dst string, timeout time.Duration) (el string, err error)

BRPopLPush is the blocking variant of RPopLPush

func (*Conn) BZPopMax

func (conn *Conn) BZPopMax(timeout time.Duration, key string, keys ...string) (z ZPop, err error)

BZPopMax is the blocking version of ZPopMax

func (*Conn) BZPopMin

func (conn *Conn) BZPopMin(timeout time.Duration, key string, keys ...string) (z ZPop, err error)

BZPopMin is the blocking version of ZPopMin

func (*Conn) Close

func (conn *Conn) Close() error

Close closes a redis connection

func (*Conn) Dirty

func (conn *Conn) Dirty() bool

Dirty checkd if a connection has pending replies to scan

func (*Conn) DoBatch

func (c *Conn) DoBatch(b *Batch) error

DoBatch executes a batch

func (*Conn) DoCommand

func (conn *Conn) DoCommand(dest interface{}, name string, args ...Arg) error

DoCommand executes a redis command

func (*Conn) Err

func (conn *Conn) Err() error

Err checks if the connection has an error

func (*Conn) Eval

func (conn *Conn) Eval(dest interface{}, script string, numKeys int, args ...string) error

Eval evaluates a Lua script

func (*Conn) LoadScript

func (conn *Conn) LoadScript(script string) (string, error)

LoadScript loads a Lua script

func (*Conn) Pipeline

func (c *Conn) Pipeline() (*Pipeline, error)

Pipeline manages a connection for easier usage

func (*Conn) Reset

func (conn *Conn) Reset(options *ConnOptions) error

Reset resets the connection to a state as defined by the options

func (*Conn) Scan

func (conn *Conn) Scan(dest interface{}) error

Scan decodes a reply to dest If so keep the deadline(?) so an appropriate timeout is set next time XXX (see below) Other solution: return an error on write if a blocking command skips the reply Edit: This is nuts, the timeout is on the server. Since we are writing the command in a pipeline we cannot know when the server will set the timeout It's plain and simple to only allow blocking commands on a `clean` connection and handle the timeouts appropriately there. XXX (see below) OTOH it's plausible that a blocking command could be the last step in a MULTI/EXEC transaction Edit: From testing via redis-cli it seems that the server does *NOT* respect the timeout when a blocking command is inside MULTI/EXEC block It executes the pop immediately if a value is available or return a nil response Edit: This is also the case for client reply skip followed by BLPOP... Edit: CLIENT REPLY SKIP and blocking commands don't mix well If an error occurs because the command was wrong nothing is returned Otherwise the SKIP is ignored and does *NOT* carry over to the next command Because of all these intricacies the best thing to do is to a) disallow client reply subcommand entirely and only use it internally - DONE b) ignore the timeout of blocking commands when queued - DONE c) maybe change the way timeout is stored in an `cmd.Entry`

so that it stores the deadline when it is written to the pipeline
This is not urgent as setting a lax deadline is not so harmful if
the connection is healthy

func (*Conn) ScanMulti

func (conn *Conn) ScanMulti(dest ...interface{}) error

ScanMulti scans the results of a MULTI/EXEC transaction

func (*Conn) Subscriber

func (conn *Conn) Subscriber(queueSize int) (*Subscriber, error)

Subscriber enables pub/sub subscriber mode for a connection

func (*Conn) WriteCommand

func (conn *Conn) WriteCommand(name string, args ...Arg) error

WriteCommand writes a redis command to the pipeline buffer updating the state

func (*Conn) WriteEval

func (conn *Conn) WriteEval(script string, numKeys int, args ...string) error

WriteEval is a convenience wrapper for WriteCommand

func (*Conn) WriteQuick

func (conn *Conn) WriteQuick(name, key string, args ...string) error

WriteQuick is a convenience wrapper for WriteCommand

type ConnOptions

type ConnOptions struct {
	ReadBufferSize  int           // Size of the read buffer
	WriteBufferSize int           // Size of the write buffer
	ReadTimeout     time.Duration // If > 0 all reads will fail if exceeded
	WriteTimeout    time.Duration // If > 0 all writes will fail if exceeded
	WriteOnly       bool          // WriteOnly connections return no replies
	DB              int           // Redis DB index
	KeyPrefix       string        // Prefix all keys
	Auth            string        // Redis auth
	Debug           bool          // Disables script injection
}

ConnOptions holds connection options

type DialFunc

type DialFunc func() (*Conn, error)

DialFunc dials a red.Conn

type HArg

type HArg struct {
	Field string
	Value Arg
}

HArg is a field-value pair

func H

func H(name string, value Arg) HArg

H creates a field-value pair

type HSet

type HSet []HArg

HSet is a collection of field-value pairs

type Migrate

type Migrate struct {
	Host          string
	Port          int
	DestinasionDB int
	Timeout       time.Duration
	Copy          bool
	Replace       bool
	Auth          string
	Keys          []string
}

Migrate moves data across servers

type Mode

type Mode uint

Mode defines command modes NX/XX

const (
	NX Mode
	XX
	CH
	INCR
	EX
	PX
)

Execution modes

func (Mode) CH

func (m Mode) CH() bool

CH checks if mode is CH

func (Mode) EX

func (m Mode) EX() bool

EX checks if mode is EX

func (Mode) INCR

func (m Mode) INCR() bool

INCR checks if mode is INCR

func (Mode) NX

func (m Mode) NX() bool

NX checks if mode is NX

func (Mode) PX

func (m Mode) PX() bool

PX checks if mode is PX

func (Mode) String

func (m Mode) String() string

func (Mode) XX

func (m Mode) XX() bool

XX checks if mode is XX

type Pipeline

type Pipeline struct {
	Batch
	// contains filtered or unexported fields
}

Pipeline is a connection manager for easy pipelining

func (*Pipeline) Append

func (b *Pipeline) Append(key, value string) *ReplyBulkString

Append appends a string to a value of a key

func (*Pipeline) Close

func (p *Pipeline) Close() error

Close closes a pipeline releasing the managed connection

func (*Pipeline) Decr

func (b *Pipeline) Decr(key string) *ReplyInteger

Decr decrements key by 1

func (*Pipeline) DecrBy

func (b *Pipeline) DecrBy(key string, d int64) *ReplyInteger

DecrBy decrements key by n

func (*Pipeline) Del

func (b *Pipeline) Del(key string, keys ...string) *ReplyInteger

Del adds a DEL command to the pipeline

func (*Pipeline) Do

func (b *Pipeline) Do(cmd string, args ...Arg) *ReplyAny

func (*Pipeline) Dump

func (b *Pipeline) Dump(key string) *ReplyBulkString

Dump adds a DUMP command

func (*Pipeline) Exists

func (b *Pipeline) Exists(keys ...string) *ReplyInteger

Exists is redis EXISTS command

func (*Pipeline) Expire

func (b *Pipeline) Expire(key string, ttl time.Duration) *ReplyInteger

Expire is redis EXPIRE command

func (*Pipeline) ExpireAt

func (b *Pipeline) ExpireAt(key string, tm time.Time) *ReplyInteger

ExpireAt is redis EXPIREAT command

func (*Pipeline) FlushDB

func (b *Pipeline) FlushDB(async bool) *ReplyOK

FlushDB writes a redis FLUSHDB command

func (*Pipeline) Get

func (b *Pipeline) Get(key string) *ReplyBulkString

Get returns the string value of a key

func (*Pipeline) GetRange

func (b *Pipeline) GetRange(key string, start, end int64) *ReplyBulkString

GetRange gets a part of a string

func (*Pipeline) GetSet

func (b *Pipeline) GetSet(key, value string) *ReplyBulkString

GetSet atomicaly replaces a value returning the old value

func (*Pipeline) HDel

func (b *Pipeline) HDel(key, field string, fields ...string) *ReplyInteger

HDel deletes fields from a map

func (*Pipeline) HExists

func (b *Pipeline) HExists(key, field string) *ReplyBool

HExists checks if a field exists in a map

func (*Pipeline) HGet

func (b *Pipeline) HGet(key, field string) *ReplyBulkString

HGet gets a map field value

func (*Pipeline) HGetAll

func (b *Pipeline) HGetAll(key string) *ReplyBulkStringArray

HGetAll gets all field/value pairs in a map

func (*Pipeline) HIncrBy

func (b *Pipeline) HIncrBy(key, field string, incr int64) *ReplyInteger

HIncrBy increments a field in a map

func (*Pipeline) HIncrByFloat

func (b *Pipeline) HIncrByFloat(key, field string, incr float64) *ReplyFloat

HIncrByFloat increments a field in a map by a float value

func (*Pipeline) HKeys

func (b *Pipeline) HKeys(key string) *ReplyBulkStringArray

HKeys gets all field keys in a map

func (*Pipeline) HLen

func (b *Pipeline) HLen(key string) *ReplyInteger

HLen returns the number of fields in a map

func (*Pipeline) HMGet

func (b *Pipeline) HMGet(key, field string, fields ...string) *ReplyBulkStringArray

HMGet returns the values associated with the specified fields in the hash stored at key. For convenience in cases where the fields are already an array the first field is compared to `field`

func (*Pipeline) HSet

func (b *Pipeline) HSet(key, field, value string, entries ...string) *ReplyInteger

HSet adds an HSet command to the pipeline

func (*Pipeline) HSetArg

func (b *Pipeline) HSetArg(key string, field string, value Arg, entries ...HArg) *ReplyInteger

HSetArg adds an HSet command to the pipeline using Arg

func (*Pipeline) HSetNX

func (b *Pipeline) HSetNX(key, field, value string) *ReplyBool

HSetNX sets the value of a new field in a map

func (*Pipeline) HSetNXArg

func (b *Pipeline) HSetNXArg(key, field string, value Arg) *ReplyBool

HSetNXArg sets the value of a new field in a map using Arg

func (*Pipeline) HStrLen

func (b *Pipeline) HStrLen(key, field string) *ReplyInteger

HStrLen returns the string length of the value of a field in a map

func (*Pipeline) HVals

func (b *Pipeline) HVals(key string) *ReplyBulkStringArray

HVals returns the values of all fields in a map

func (*Pipeline) Incr

func (b *Pipeline) Incr(key string) *ReplyInteger

Incr increments key by 1

func (*Pipeline) IncrBy

func (b *Pipeline) IncrBy(key string, n int64) *ReplyInteger

IncrBy incremments the value at a key by an integer amount

func (*Pipeline) IncrByFloat

func (b *Pipeline) IncrByFloat(key string, incr float64) *ReplyFloat

IncrByFloat incremments the value at a key by a float amount

func (*Pipeline) Keys

func (b *Pipeline) Keys(pattern string) *ReplyBulkStringArray

Keys returns all keys matching a pattern

func (*Pipeline) LIndex

func (c *Pipeline) LIndex(key string, index int64) *ReplyInteger

LIndex returns the element at index index in the list stored at key.

func (*Pipeline) LInsertAfter

func (c *Pipeline) LInsertAfter(key string, pivot int64, value Arg) *ReplyInteger

LInsertAfter inserts element in the list stored at key after the reference value pivot. LINSERT key AFTER pivot element

func (*Pipeline) LInsertBefore

func (c *Pipeline) LInsertBefore(key string, pivot int64, value Arg) *ReplyInteger

LInsertBefore inserts element in the list stored at key before the reference value pivot. LINSERT key BEFORE pivot element

func (*Pipeline) LLen

func (c *Pipeline) LLen(key string) *ReplyInteger

LLen returns the length of the list stored at key.

func (*Pipeline) LPop

func (c *Pipeline) LPop(key string) *ReplyBulkString

LPop removes and returns the first element of the list stored at key.

func (*Pipeline) LPush

func (c *Pipeline) LPush(key string, values ...Arg) *ReplyInteger

LPush inserts specified values at the head of the list stored at key.

func (*Pipeline) LPushX

func (c *Pipeline) LPushX(key string, values ...Arg) *ReplyInteger

LPushX inserts specified values at the head of the list stored at key, only if key already exists and holds a list.

func (*Pipeline) LRange

func (c *Pipeline) LRange(key string, start, stop int64) *ReplyBulkStringArray

LRange returns the specified elements of the list stored at key. LRANGE key start stop

func (*Pipeline) LRem

func (c *Pipeline) LRem(key string, count int64, element Arg) *ReplyInteger

LRem removes the first count occurrences of elements equal to element from the list stored at key.

func (*Pipeline) LSet

func (c *Pipeline) LSet(key string, index int64, element Arg) *ReplyOK

LSet sets list element at index to element.

func (*Pipeline) LTrim

func (c *Pipeline) LTrim(key string, start, stop int64) *ReplyInteger

LTrim trims an existing list so that it will contain only the specified range of elements specified.

func (*Pipeline) MGet

func (b *Pipeline) MGet(key string, keys ...string) *ReplyBulkStringArray

MGet gets multiple key values

func (*Pipeline) MSet

func (b *Pipeline) MSet(values ...string) *ReplyOK

MSet sets multiple keys

func (*Pipeline) MSetArg

func (b *Pipeline) MSetArg(values map[string]Arg) *ReplyOK

MSetArg sets multiple keys

func (*Pipeline) MSetNX

func (b *Pipeline) MSetNX(values ...string) *ReplyBool

MSetNX sets multiple keys if they do not exist

func (*Pipeline) Migrate

func (b *Pipeline) Migrate(m Migrate) *ReplyOK

Migrate moves data across servers

func (*Pipeline) Move

func (b *Pipeline) Move(key string, db int) *ReplyInteger

Move moves a key to a different DB index

func (*Pipeline) ObjectEncoding

func (b *Pipeline) ObjectEncoding(key string) *ReplyBulkString

ObjectEncoding is the redis' OBJECT ENCODING command

func (*Pipeline) ObjectFreq

func (b *Pipeline) ObjectFreq(key string) *ReplyInteger

ObjectFreq is the redis' OBJECT FREQ command

func (*Pipeline) ObjectHelp

func (b *Pipeline) ObjectHelp(key string) *ReplyBulkString

ObjectHelp is the redis' OBJECT HELP command

func (*Pipeline) ObjectIdleTime

func (b *Pipeline) ObjectIdleTime(key string) *ReplyInteger

ObjectIdleTime is the redis' OBJECT IDLETIME command

func (*Pipeline) ObjectRefCount

func (b *Pipeline) ObjectRefCount(key string) *ReplyInteger

ObjectRefCount is the redis' OBJECT REFCOUNT command

func (*Pipeline) PExpire

func (b *Pipeline) PExpire(key string, ttl time.Duration) *ReplyInteger

PExpire adds a TTL to a key in milliseconds

func (*Pipeline) PExpireAt

func (b *Pipeline) PExpireAt(key string, tm time.Time) *ReplyInteger

PExpireAt is redis PEXPIREAT command

func (*Pipeline) PTTL

func (b *Pipeline) PTTL(key string) *ReplyInteger

PTTL gets the TTL of a key in milliseconds

func (*Pipeline) Persist

func (b *Pipeline) Persist(key string) *ReplyInteger

Persist removes any TTL from a key

func (Pipeline) PubSubChannels

func (b Pipeline) PubSubChannels(pattern string) *ReplyBulkStringArray

PubSubChannels lists all active channels. PUBSUB CHANNELS [pattern] If no pattern is specified all channels are listed, otherwise if pattern is specified only channels matching the specified glob-style pattern are listed.

func (*Pipeline) PubSubNumPat

func (b *Pipeline) PubSubNumPat() *ReplyInteger

PubSubNumPat returns the number of subscriptions to patterns (that are performed using the PSUBSCRIBE command). Note that this is not just the count of clients subscribed to patterns but the total number of patterns all the clients are subscribed to. PUBSUB NUMPAT

func (*Pipeline) PubSubNumSub

func (b *Pipeline) PubSubNumSub(channels ...string) *ReplyInteger

PubSubNumSub returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels. PUBSUB NUMSUB [channel-1 ... channel-N]

func (*Pipeline) Publish

func (b *Pipeline) Publish(channel, msg string) *ReplyInteger

Publish publishes a message on a channel

func (*Pipeline) RPop

func (c *Pipeline) RPop(key string) *ReplyBulkString

RPop removes and returns the last element of the list stored at key.

func (*Pipeline) RPopLPush

func (c *Pipeline) RPopLPush(src, dest string, timeout time.Duration) *ReplyBulkString

RPopLPush atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.

func (*Pipeline) RPush

func (c *Pipeline) RPush(key string, elements ...Arg) *ReplyInteger

RPush inserts specified values at the tail of the list stored at key.

func (*Pipeline) RPushX

func (c *Pipeline) RPushX(key string, elements ...Arg) *ReplyInteger

RPushX Inserts specified values at the tail of the list stored at key, only if key already exists and holds a list.

func (*Pipeline) RandomKey

func (b *Pipeline) RandomKey() *ReplyBulkString

RandomKey returns a random key

func (*Pipeline) Rename

func (b *Pipeline) Rename(key, newkey string) *ReplyOK

Rename renames a key

func (*Pipeline) RenameNX

func (b *Pipeline) RenameNX(key, newkey string) *ReplyOK

RenameNX renames a key if the new name does not exist

func (*Pipeline) Restore

func (b *Pipeline) Restore(r Restore) *ReplyOK

Restore restores a key value from a string

func (*Pipeline) Set

func (b *Pipeline) Set(key, value string, ttl time.Duration) *ReplyOK

Set sets a key to value

func (*Pipeline) SetEX

func (b *Pipeline) SetEX(key, value string, ttl time.Duration) *ReplyOK

SetEX sets a key with a ttl

func (*Pipeline) SetNX

func (b *Pipeline) SetNX(key, value string, ttl time.Duration) *ReplyOK

SetNX sets a new key value

func (*Pipeline) SetRange

func (b *Pipeline) SetRange(key string, offset int64, value string) *ReplyBulkString

SetRange sets a part of a string

func (*Pipeline) SetXX

func (b *Pipeline) SetXX(key, value string, ttl time.Duration) *ReplyOK

SetXX resets a key value if it exists

func (*Pipeline) Sort

func (b *Pipeline) Sort(key string, sort Sort) *ReplyBulkStringArray

Sort sorts a key's values

func (*Pipeline) SortStore

func (b *Pipeline) SortStore(dest, key string, sort Sort) *ReplyInteger

SortStore sorts a `key`'s value storing the result in `dest`

func (*Pipeline) StrLen

func (b *Pipeline) StrLen(key string) *ReplyBulkString

StrLen return the length of a string value

func (*Pipeline) Sync

func (p *Pipeline) Sync() error

Sync syncs all queued commands in the pipeline

func (*Pipeline) TTL

func (b *Pipeline) TTL(key string) *ReplyInteger

TTL returns the remaining lifetime of a key in seconds

func (*Pipeline) Touch

func (b *Pipeline) Touch(keys ...string) *ReplyInteger

Touch alters the last access time of a key(s).

func (*Pipeline) Type

func (b *Pipeline) Type(key string) *ReplySimpleString

Type returns the type of the value of a key

func (b *Pipeline) Unlink(keys ...string) *ReplyInteger

Unlink drops keys

func (*Pipeline) Wait

func (b *Pipeline) Wait(numReplicas int, timeout time.Duration) *ReplyInteger

Wait blocks until a number of replicas have stored the data or timeout occured

func (*Pipeline) XAck

func (b *Pipeline) XAck(key, group string, id string, ids ...string) *ReplyInteger

XAck removes one or multiple messages from the pending entries list (PEL) of a stream consumer group. XACK key group ID [ID ...]

func (*Pipeline) XAdd

func (b *Pipeline) XAdd(key string, maxLen int64, id string, fields ...HArg) *ReplyBulkString

XAdd appends the specified stream entry to the stream at the specified key.

XADD key ID field value [field value ...]

If the key does not exist, as a side effect of running this command, the key is created with a stream value.

func (*Pipeline) XDel

func (b *Pipeline) XDel(key string, ids ...string) *ReplyInteger

XDel deletes entries from a stream

func (*Pipeline) XGroupCreate

func (b *Pipeline) XGroupCreate(key, group, id string, makeStream bool) *ReplyOK

XGroupCreate creates a new consumer group associated with a stream. XGROUP [CREATE key groupname id-or-$]

func (*Pipeline) XGroupDelConsumer

func (b *Pipeline) XGroupDelConsumer(key, group, consumer string) *ReplyInteger

XGroupDelConsumer removes a specific consumer from a consumer group

func (*Pipeline) XGroupDestroy

func (b *Pipeline) XGroupDestroy(key, group string) *ReplyInteger

XGroupDestroy destroys a consumer group

func (*Pipeline) XGroupSetID

func (b *Pipeline) XGroupSetID(key, group, id string) *ReplyOK

XGroupSetID sets the consumer group last delivered ID to something else. XGROUP [SETID key groupname id-or-$]

func (*Pipeline) XInfoConsumers

func (b *Pipeline) XInfoConsumers(key, group string) *ReplyXInfoConsumers

XInfoConsumers returns the list of every consumer in a specific consumer group

func (*Pipeline) XInfoGroups

func (b *Pipeline) XInfoGroups(key string) *ReplyXInfoGroups

XInfoGroups returns all the consumer groups associated with the stream.

func (*Pipeline) XInfoHelp

func (b *Pipeline) XInfoHelp() *ReplyBulkStringArray

XInfoHelp gets help for XINFO command

func (*Pipeline) XInfoStream

func (b *Pipeline) XInfoStream(key string) *ReplyXInfoStream

XInfoStream returns general information about the stream stored at the specified key.

func (*Pipeline) XLen

func (b *Pipeline) XLen(key string) *ReplyInteger

XLen returns the number of entries inside a stream.

func (*Pipeline) XPending

func (b *Pipeline) XPending(key, group string) *ReplyXPendingSummary

func (*Pipeline) XPendingConsumer

func (b *Pipeline) XPendingConsumer(args XPending) *ReplyXPending

func (*Pipeline) XPendingGroup

func (b *Pipeline) XPendingGroup(args XPending) *ReplyXPending

func (*Pipeline) XRange

func (b *Pipeline) XRange(key, group, start, end string, count int64) *ReplyXRange

Command implements Commander interface

func (*Pipeline) XRevRange

func (b *Pipeline) XRevRange(key, group, end, start string, count int64) *ReplyXRange

func (*Pipeline) ZAdd

func (b *Pipeline) ZAdd(key string, mode Mode, members ...ZEntry) *ReplyInteger

ZAdd adds or modifies the a member of a sorted set

func (*Pipeline) ZAddIncr

func (b *Pipeline) ZAddIncr(key string, mode Mode, member string, d float64) *ReplyFloat

ZAddIncr increments the score of a sorted set member by d

func (*Pipeline) ZCard

func (b *Pipeline) ZCard(key string) *ReplyInteger

ZCard returns the cardinality of a sorted set

func (*Pipeline) ZCount

func (b *Pipeline) ZCount(key string, min, max Arg) *ReplyInteger

ZCount returns the number of elements in the sorted set at key with a score between min and max.

func (*Pipeline) ZIncrBy

func (b *Pipeline) ZIncrBy(key string, incr float64, member string) *ReplyFloat

ZIncrBy increments the score of member in the sorted set stored at key by increment.

func (*Pipeline) ZInterStore

func (b *Pipeline) ZInterStore(args ZStore) *ReplyInteger

ZInterStore computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in destination.

func (*Pipeline) ZLexCount

func (b *Pipeline) ZLexCount(key string, min, max Arg) *ReplyInteger

ZLexCount returns the number of elements in the sorted set at key with a value between min and max.

func (*Pipeline) ZPopMax

func (b *Pipeline) ZPopMax(key string, count int64) *ReplyZRange

ZPopMax removes and returns up to count members with the highest scores in the sorted set stored at key.

func (*Pipeline) ZPopMin

func (b *Pipeline) ZPopMin(key string, count int64) *ReplyZRange

ZPopMin removes and returns up to count members with the lowest scores in the sorted set stored at key.

func (*Pipeline) ZRange

func (b *Pipeline) ZRange(key string, start, stop int64) *ReplyBulkStringArray

ZRange returns the specified range of elements in the sorted set stored at key.

func (*Pipeline) ZRangeByLex

func (b *Pipeline) ZRangeByLex(key string, min, max Arg, offset, count int64) *ReplyBulkStringArray

ZRangeByLex when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returnWhen all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.s all the elements in the sorted set at key with a value between min and max.

func (*Pipeline) ZRangeByScore

func (b *Pipeline) ZRangeByScore(key string, min, max Arg, offset, count int64) *ReplyBulkStringArray

ZRangeByScore returns all the elements in the sorted set at key with a score between min and max

func (*Pipeline) ZRangeByScoreWithScores

func (b *Pipeline) ZRangeByScoreWithScores(key string, min, max Arg, offset, count int64) *ReplyZRange

ZRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max

func (*Pipeline) ZRangeWithScores

func (b *Pipeline) ZRangeWithScores(key string, start, stop int64) *ReplyZRange

ZRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*Pipeline) ZRank

func (b *Pipeline) ZRank(key, member string) *ReplyInteger

ZRank gets the rank of a member of a sorted set ordered from low to high

func (*Pipeline) ZRem

func (b *Pipeline) ZRem(key string, members ...string) *ReplyInteger

ZRem removes member(s) from a sorted set

func (*Pipeline) ZRemRangeByLex

func (b *Pipeline) ZRemRangeByLex(key string, min, max Arg) *ReplyInteger

ZRemRangeByLex removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.

func (*Pipeline) ZRemRangeByRank

func (b *Pipeline) ZRemRangeByRank(key string, start, stop int64) *ReplyInteger

ZRemRangeByRank removes all elements in the sorted set stored at key with rank between start and stop.

func (*Pipeline) ZRemRangeByScore

func (b *Pipeline) ZRemRangeByScore(key string, min, max Arg) *ReplyInteger

ZRemRangeByScore removes all elements in the sorted set stored at key with a score between min and max (inclusive).

func (*Pipeline) ZRevRange

func (b *Pipeline) ZRevRange(key string, start, stop int64) *ReplyBulkStringArray

ZRevRange returns the specified range of elements in the sorted set stored at key.

func (*Pipeline) ZRevRangeByLex

func (b *Pipeline) ZRevRangeByLex(key string, max, min Arg, offset, count int64) *ReplyBulkStringArray

ZRevRangeByLex when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returnWhen all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.s all the elements in the sorted set at key with a value between min and max.

func (*Pipeline) ZRevRangeByScore

func (b *Pipeline) ZRevRangeByScore(key string, max, min Arg, offset, count int64) *ReplyBulkStringArray

ZRevRangeByScore returns all the elements in the sorted set at key with a score between min and max

func (*Pipeline) ZRevRangeByScoreWithScores

func (b *Pipeline) ZRevRangeByScoreWithScores(key string, max, min Arg, offset, count int64) *ReplyZRange

ZRevRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max

func (*Pipeline) ZRevRangeWithScores

func (b *Pipeline) ZRevRangeWithScores(key string, start, stop int64) *ReplyZRange

ZRevRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*Pipeline) ZRevRank

func (b *Pipeline) ZRevRank(key, member string) *ReplyInteger

ZRevRank gets the rank of a member of a sorted set ordered from high to low

func (*Pipeline) ZScore

func (b *Pipeline) ZScore(key, member string) *ReplyFloat

ZScore returns the score of a member

func (*Pipeline) ZUnionStore

func (b *Pipeline) ZUnionStore(args ZStore) *ReplyInteger

ZUnionStore computes the union of numkeys sorted sets given by the specified keys, and stores the result in destination.

type PipelineWriter

type PipelineWriter struct {
	KeyPrefix string
	// contains filtered or unexported fields
}

func (*PipelineWriter) Flush

func (w *PipelineWriter) Flush() error

Flush flushes the underlying writer

func (*PipelineWriter) Reset

func (w *PipelineWriter) Reset(dest *bufio.Writer)

func (*PipelineWriter) WriteCommand

func (w *PipelineWriter) WriteCommand(cmd string, args ...Arg) (err error)

WriteCommand writes a redis command

type Pool

type Pool struct {
	Dial           func() (*Conn, error) // Dialer for redis connections (required)
	MaxConnections int                   // Maximum number of connection to open on demand (defaults to 1)
	MinConnections int                   // Minimum number of connections to keep open once dialed (defaults to 1)
	MaxIdleTime    time.Duration         // Max time a connection will be left idling (0 => no limit)
	ClockInterval  time.Duration         // Minimum unit of time for timeouts and intervals (defaults to 50ms)
	// contains filtered or unexported fields
}

Pool is a pool of redis connections

func ParseURL

func ParseURL(redisURL string) (*Pool, error)

ParseURL parses a URL to PoolOptions

func (*Pool) Close

func (p *Pool) Close() error

Close closes a pool and all it's connections TODO: [pool] Implement grace period for when closing a pool

func (*Pool) DoBatch

func (p *Pool) DoBatch(b *Batch) error

DoBatch executes a batch on a pool connection

func (*Pool) DoCommand

func (p *Pool) DoCommand(dest interface{}, cmd string, args ...Arg) error

DoCommand executes cmd on a new connection

func (*Pool) Get

func (p *Pool) Get() (*Conn, error)

Get waits indefinitely to get a connection from the pool

To release the connection back to the pool use `Pool.Put(*Conn)`

func (*Pool) GetDeadline

func (p *Pool) GetDeadline(deadline time.Time) (c *Conn, err error)

GetDeadline waits until deadline for a connection

func (*Pool) GetTimeout

func (p *Pool) GetTimeout(timeout time.Duration) (*Conn, error)

GetTimeout waits `timeout` to get a connection from the pool

To release the connection back to the pool use `Pool.Put(*Conn)`

func (*Pool) Stats

func (p *Pool) Stats() PoolStats

Stats returns current pool statistics

type PoolStats

type PoolStats struct {
	Hits, Misses, Timeouts, Dials int64
	Idle, Active                  int
}

PoolStats counts pool statistics

type Pop

type Pop struct {
	Key   string
	Value string
}

func (*Pop) UnmarshalRESP

func (p *Pop) UnmarshalRESP(v resp.Value) error

type PubSubMessage

type PubSubMessage struct {
	Channel string
	Payload string
}

PubSubMessage is a message from a PUB/SUB channel

type ReplyAny

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

ReplyAny is a redis reply of any kind

func (*ReplyAny) Bind

func (r *ReplyAny) Bind(dest interface{})

func (*ReplyAny) Err

func (r *ReplyAny) Err() error

func (*ReplyAny) Reply

func (r *ReplyAny) Reply() (resp.Any, error)

Reply returns the reply as a resp.Any value

type ReplyBool

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

ReplyBool is a redis integer reply with values 1 or 0

func (*ReplyBool) Bind

func (r *ReplyBool) Bind(dest interface{})

func (*ReplyBool) Err

func (r *ReplyBool) Err() error

func (*ReplyBool) Reply

func (r *ReplyBool) Reply() (bool, error)

Reply returns the boolean reply

type ReplyBulkString

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

ReplyBulkString is a single bulk string reply

func (*ReplyBulkString) Bind

func (r *ReplyBulkString) Bind(dest interface{})

func (*ReplyBulkString) Err

func (r *ReplyBulkString) Err() error

func (*ReplyBulkString) Reply

func (r *ReplyBulkString) Reply() (string, error)

Reply returns the bulk string

type ReplyBulkStringArray

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

ReplyBulkStringArray is a redis array reply with non-null bulk string elements

func (*ReplyBulkStringArray) Bind

func (r *ReplyBulkStringArray) Bind(dest interface{})

func (*ReplyBulkStringArray) Err

func (r *ReplyBulkStringArray) Err() error

func (*ReplyBulkStringArray) Reply

func (r *ReplyBulkStringArray) Reply() ([]string, error)

Reply returns the strings reply

type ReplyFloat

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

ReplyFloat is a redis bulk string reply that is parsed as a float

func (*ReplyFloat) Bind

func (r *ReplyFloat) Bind(dest interface{})

func (*ReplyFloat) Err

func (r *ReplyFloat) Err() error

func (*ReplyFloat) Reply

func (r *ReplyFloat) Reply() (float64, error)

Reply returns the float value

type ReplyInteger

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

ReplyInteger is a redis integer reply

func (*ReplyInteger) Bind

func (r *ReplyInteger) Bind(dest interface{})

func (*ReplyInteger) Err

func (r *ReplyInteger) Err() error

func (*ReplyInteger) Reply

func (r *ReplyInteger) Reply() (int64, error)

Reply returns the integer value

type ReplyOK

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

ReplyOK is a redis "OK" status reply

func (*ReplyOK) Bind

func (r *ReplyOK) Bind(dest interface{})

func (*ReplyOK) Err

func (r *ReplyOK) Err() error

func (*ReplyOK) Reply

func (r *ReplyOK) Reply() (ok bool, err error)

Reply returns if the status was OK

type ReplySimpleString

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

ReplySimpleString is a redis status reply

func (*ReplySimpleString) Bind

func (r *ReplySimpleString) Bind(dest interface{})

func (*ReplySimpleString) Err

func (r *ReplySimpleString) Err() error

func (*ReplySimpleString) Reply

func (r *ReplySimpleString) Reply() (string, error)

Reply returns the status reply

type ReplyTX

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

ReplyTX is the reply from a MULTI/EXEC transaction

func (*ReplyTX) Bind

func (r *ReplyTX) Bind(dest interface{})

func (*ReplyTX) Err

func (r *ReplyTX) Err() error

type ReplyXInfoConsumers

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

func (*ReplyXInfoConsumers) Bind

func (r *ReplyXInfoConsumers) Bind(dest interface{})

func (*ReplyXInfoConsumers) Err

func (r *ReplyXInfoConsumers) Err() error

func (*ReplyXInfoConsumers) Reply

func (r *ReplyXInfoConsumers) Reply() ([]XInfoConsumer, error)

type ReplyXInfoGroups

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

func (*ReplyXInfoGroups) Bind

func (r *ReplyXInfoGroups) Bind(dest interface{})

func (*ReplyXInfoGroups) Err

func (r *ReplyXInfoGroups) Err() error

func (*ReplyXInfoGroups) Reply

func (r *ReplyXInfoGroups) Reply() ([]XInfoGroup, error)

type ReplyXInfoStream

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

func (*ReplyXInfoStream) Bind

func (r *ReplyXInfoStream) Bind(dest interface{})

func (*ReplyXInfoStream) Err

func (r *ReplyXInfoStream) Err() error

func (*ReplyXInfoStream) Reply

func (r *ReplyXInfoStream) Reply() (XInfoStream, error)

type ReplyXPending

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

func (*ReplyXPending) Bind

func (r *ReplyXPending) Bind(dest interface{})

func (*ReplyXPending) Err

func (r *ReplyXPending) Err() error

func (*ReplyXPending) Reply

func (r *ReplyXPending) Reply() ([]XPendingEntry, error)

type ReplyXPendingSummary

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

func (*ReplyXPendingSummary) Bind

func (r *ReplyXPendingSummary) Bind(dest interface{})

func (*ReplyXPendingSummary) Err

func (r *ReplyXPendingSummary) Err() error

func (*ReplyXPendingSummary) Reply

type ReplyXRange

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

func (*ReplyXRange) Bind

func (r *ReplyXRange) Bind(dest interface{})

func (*ReplyXRange) Err

func (r *ReplyXRange) Err() error

func (*ReplyXRange) Reply

func (r *ReplyXRange) Reply() ([]StreamRecord, error)

type ReplyZPop

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

ReplyZPop is the reply of a BZPOPMIN/BZPOPMAX command

func (*ReplyZPop) Bind

func (r *ReplyZPop) Bind(dest interface{})

func (*ReplyZPop) Err

func (r *ReplyZPop) Err() error

func (*ReplyZPop) Reply

func (reply *ReplyZPop) Reply() (ZPop, error)

Reply returns the BZPOPMIN/BZPOPMAX reply

type ReplyZRange

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

ReplyZRange is a map of members with scores

func (*ReplyZRange) Bind

func (r *ReplyZRange) Bind(dest interface{})

func (*ReplyZRange) Err

func (r *ReplyZRange) Err() error

func (*ReplyZRange) Reply

func (r *ReplyZRange) Reply() ([]ZEntry, error)

Reply return the reply

type Restore

type Restore struct {
	Key         string
	TTL         time.Duration
	Value       string
	Replace     bool
	AbsoluteTTL bool
	IdleTime    time.Duration
	Frequency   int64
}

Restore restores a key value from a string

type Sort

type Sort struct {
	By           string
	Offset       int64
	Count        int64
	Get          []string
	Order        SortOrder
	Alphanumeric bool
}

Sort sorts keys

type SortOrder

type SortOrder int

SortOrder defines sorting order

const (
	SortAscending SortOrder
	SortDescending
)

Sort orders ASC=1, DESC=2

func (SortOrder) String

func (o SortOrder) String() string

type StreamRecord

type StreamRecord struct {
	ID     string
	Record []HArg
}

func (*StreamRecord) UnmarshalRESP

func (s *StreamRecord) UnmarshalRESP(v resp.Value) error

UnmarshalRESP implements resp.Unmarshaler interface

type Subscriber

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

Subscriber subscribes to redis PUB/SUB channels

func (*Subscriber) Block

func (sub *Subscriber) Block() (*PubSubMessage, error)

Block waits forever for a message

func (*Subscriber) Close

func (sub *Subscriber) Close() (err error)

Close closes the subscriber

func (*Subscriber) Get

func (sub *Subscriber) Get() (*PubSubMessage, error)

Get waits timeout for a message

func (*Subscriber) Messages

func (sub *Subscriber) Messages() <-chan *PubSubMessage

Messages returns a channel of incoming PUB/SUB messages

func (*Subscriber) PSubscribe

func (sub *Subscriber) PSubscribe(patterns ...string) error

PSubscribe subscribes to channels matching patterns

func (*Subscriber) PUnsubscribe

func (sub *Subscriber) PUnsubscribe(patterns ...string) error

PUnsubscribe unsubscribes from channels matching pattenrs

func (*Subscriber) Subscribe

func (sub *Subscriber) Subscribe(channels ...string) error

Subscribe subscribes to channels

func (*Subscriber) Unsubscribe

func (sub *Subscriber) Unsubscribe(channels ...string) error

Unsubscribe unsubscribes from channels

func (*Subscriber) Wait

func (sub *Subscriber) Wait(timeout time.Duration) (*PubSubMessage, error)

Wait waits `timeout` for a message

type Tx

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

Tx is a MULTI/EXEC transaction block

func (*Tx) Append

func (b *Tx) Append(key, value string) *ReplyBulkString

Append appends a string to a value of a key

func (*Tx) Decr

func (b *Tx) Decr(key string) *ReplyInteger

Decr decrements key by 1

func (*Tx) DecrBy

func (b *Tx) DecrBy(key string, d int64) *ReplyInteger

DecrBy decrements key by n

func (*Tx) Del

func (b *Tx) Del(key string, keys ...string) *ReplyInteger

Del adds a DEL command to the pipeline

func (*Tx) Do

func (b *Tx) Do(cmd string, args ...Arg) *ReplyAny

func (*Tx) Dump

func (b *Tx) Dump(key string) *ReplyBulkString

Dump adds a DUMP command

func (*Tx) Exists

func (b *Tx) Exists(keys ...string) *ReplyInteger

Exists is redis EXISTS command

func (*Tx) Expire

func (b *Tx) Expire(key string, ttl time.Duration) *ReplyInteger

Expire is redis EXPIRE command

func (*Tx) ExpireAt

func (b *Tx) ExpireAt(key string, tm time.Time) *ReplyInteger

ExpireAt is redis EXPIREAT command

func (*Tx) FlushDB

func (b *Tx) FlushDB(async bool) *ReplyOK

FlushDB writes a redis FLUSHDB command

func (*Tx) Get

func (b *Tx) Get(key string) *ReplyBulkString

Get returns the string value of a key

func (*Tx) GetRange

func (b *Tx) GetRange(key string, start, end int64) *ReplyBulkString

GetRange gets a part of a string

func (*Tx) GetSet

func (b *Tx) GetSet(key, value string) *ReplyBulkString

GetSet atomicaly replaces a value returning the old value

func (*Tx) HDel

func (b *Tx) HDel(key, field string, fields ...string) *ReplyInteger

HDel deletes fields from a map

func (*Tx) HExists

func (b *Tx) HExists(key, field string) *ReplyBool

HExists checks if a field exists in a map

func (*Tx) HGet

func (b *Tx) HGet(key, field string) *ReplyBulkString

HGet gets a map field value

func (*Tx) HGetAll

func (b *Tx) HGetAll(key string) *ReplyBulkStringArray

HGetAll gets all field/value pairs in a map

func (*Tx) HIncrBy

func (b *Tx) HIncrBy(key, field string, incr int64) *ReplyInteger

HIncrBy increments a field in a map

func (*Tx) HIncrByFloat

func (b *Tx) HIncrByFloat(key, field string, incr float64) *ReplyFloat

HIncrByFloat increments a field in a map by a float value

func (*Tx) HKeys

func (b *Tx) HKeys(key string) *ReplyBulkStringArray

HKeys gets all field keys in a map

func (*Tx) HLen

func (b *Tx) HLen(key string) *ReplyInteger

HLen returns the number of fields in a map

func (*Tx) HMGet

func (b *Tx) HMGet(key, field string, fields ...string) *ReplyBulkStringArray

HMGet returns the values associated with the specified fields in the hash stored at key. For convenience in cases where the fields are already an array the first field is compared to `field`

func (*Tx) HSet

func (b *Tx) HSet(key, field, value string, entries ...string) *ReplyInteger

HSet adds an HSet command to the pipeline

func (*Tx) HSetArg

func (b *Tx) HSetArg(key string, field string, value Arg, entries ...HArg) *ReplyInteger

HSetArg adds an HSet command to the pipeline using Arg

func (*Tx) HSetNX

func (b *Tx) HSetNX(key, field, value string) *ReplyBool

HSetNX sets the value of a new field in a map

func (*Tx) HSetNXArg

func (b *Tx) HSetNXArg(key, field string, value Arg) *ReplyBool

HSetNXArg sets the value of a new field in a map using Arg

func (*Tx) HStrLen

func (b *Tx) HStrLen(key, field string) *ReplyInteger

HStrLen returns the string length of the value of a field in a map

func (*Tx) HVals

func (b *Tx) HVals(key string) *ReplyBulkStringArray

HVals returns the values of all fields in a map

func (*Tx) Incr

func (b *Tx) Incr(key string) *ReplyInteger

Incr increments key by 1

func (*Tx) IncrBy

func (b *Tx) IncrBy(key string, n int64) *ReplyInteger

IncrBy incremments the value at a key by an integer amount

func (*Tx) IncrByFloat

func (b *Tx) IncrByFloat(key string, incr float64) *ReplyFloat

IncrByFloat incremments the value at a key by a float amount

func (*Tx) Keys

func (b *Tx) Keys(pattern string) *ReplyBulkStringArray

Keys returns all keys matching a pattern

func (*Tx) LIndex

func (c *Tx) LIndex(key string, index int64) *ReplyInteger

LIndex returns the element at index index in the list stored at key.

func (*Tx) LInsertAfter

func (c *Tx) LInsertAfter(key string, pivot int64, value Arg) *ReplyInteger

LInsertAfter inserts element in the list stored at key after the reference value pivot. LINSERT key AFTER pivot element

func (*Tx) LInsertBefore

func (c *Tx) LInsertBefore(key string, pivot int64, value Arg) *ReplyInteger

LInsertBefore inserts element in the list stored at key before the reference value pivot. LINSERT key BEFORE pivot element

func (*Tx) LLen

func (c *Tx) LLen(key string) *ReplyInteger

LLen returns the length of the list stored at key.

func (*Tx) LPop

func (c *Tx) LPop(key string) *ReplyBulkString

LPop removes and returns the first element of the list stored at key.

func (*Tx) LPush

func (c *Tx) LPush(key string, values ...Arg) *ReplyInteger

LPush inserts specified values at the head of the list stored at key.

func (*Tx) LPushX

func (c *Tx) LPushX(key string, values ...Arg) *ReplyInteger

LPushX inserts specified values at the head of the list stored at key, only if key already exists and holds a list.

func (*Tx) LRange

func (c *Tx) LRange(key string, start, stop int64) *ReplyBulkStringArray

LRange returns the specified elements of the list stored at key. LRANGE key start stop

func (*Tx) LRem

func (c *Tx) LRem(key string, count int64, element Arg) *ReplyInteger

LRem removes the first count occurrences of elements equal to element from the list stored at key.

func (*Tx) LSet

func (c *Tx) LSet(key string, index int64, element Arg) *ReplyOK

LSet sets list element at index to element.

func (*Tx) LTrim

func (c *Tx) LTrim(key string, start, stop int64) *ReplyInteger

LTrim trims an existing list so that it will contain only the specified range of elements specified.

func (*Tx) MGet

func (b *Tx) MGet(key string, keys ...string) *ReplyBulkStringArray

MGet gets multiple key values

func (*Tx) MSet

func (b *Tx) MSet(values ...string) *ReplyOK

MSet sets multiple keys

func (*Tx) MSetArg

func (b *Tx) MSetArg(values map[string]Arg) *ReplyOK

MSetArg sets multiple keys

func (*Tx) MSetNX

func (b *Tx) MSetNX(values ...string) *ReplyBool

MSetNX sets multiple keys if they do not exist

func (*Tx) Migrate

func (b *Tx) Migrate(m Migrate) *ReplyOK

Migrate moves data across servers

func (*Tx) Move

func (b *Tx) Move(key string, db int) *ReplyInteger

Move moves a key to a different DB index

func (*Tx) ObjectEncoding

func (b *Tx) ObjectEncoding(key string) *ReplyBulkString

ObjectEncoding is the redis' OBJECT ENCODING command

func (*Tx) ObjectFreq

func (b *Tx) ObjectFreq(key string) *ReplyInteger

ObjectFreq is the redis' OBJECT FREQ command

func (*Tx) ObjectHelp

func (b *Tx) ObjectHelp(key string) *ReplyBulkString

ObjectHelp is the redis' OBJECT HELP command

func (*Tx) ObjectIdleTime

func (b *Tx) ObjectIdleTime(key string) *ReplyInteger

ObjectIdleTime is the redis' OBJECT IDLETIME command

func (*Tx) ObjectRefCount

func (b *Tx) ObjectRefCount(key string) *ReplyInteger

ObjectRefCount is the redis' OBJECT REFCOUNT command

func (*Tx) PExpire

func (b *Tx) PExpire(key string, ttl time.Duration) *ReplyInteger

PExpire adds a TTL to a key in milliseconds

func (*Tx) PExpireAt

func (b *Tx) PExpireAt(key string, tm time.Time) *ReplyInteger

PExpireAt is redis PEXPIREAT command

func (*Tx) PTTL

func (b *Tx) PTTL(key string) *ReplyInteger

PTTL gets the TTL of a key in milliseconds

func (*Tx) Persist

func (b *Tx) Persist(key string) *ReplyInteger

Persist removes any TTL from a key

func (Tx) PubSubChannels

func (b Tx) PubSubChannels(pattern string) *ReplyBulkStringArray

PubSubChannels lists all active channels. PUBSUB CHANNELS [pattern] If no pattern is specified all channels are listed, otherwise if pattern is specified only channels matching the specified glob-style pattern are listed.

func (*Tx) PubSubNumPat

func (b *Tx) PubSubNumPat() *ReplyInteger

PubSubNumPat returns the number of subscriptions to patterns (that are performed using the PSUBSCRIBE command). Note that this is not just the count of clients subscribed to patterns but the total number of patterns all the clients are subscribed to. PUBSUB NUMPAT

func (*Tx) PubSubNumSub

func (b *Tx) PubSubNumSub(channels ...string) *ReplyInteger

PubSubNumSub returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels. PUBSUB NUMSUB [channel-1 ... channel-N]

func (*Tx) Publish

func (b *Tx) Publish(channel, msg string) *ReplyInteger

Publish publishes a message on a channel

func (*Tx) RPop

func (c *Tx) RPop(key string) *ReplyBulkString

RPop removes and returns the last element of the list stored at key.

func (*Tx) RPopLPush

func (c *Tx) RPopLPush(src, dest string, timeout time.Duration) *ReplyBulkString

RPopLPush atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.

func (*Tx) RPush

func (c *Tx) RPush(key string, elements ...Arg) *ReplyInteger

RPush inserts specified values at the tail of the list stored at key.

func (*Tx) RPushX

func (c *Tx) RPushX(key string, elements ...Arg) *ReplyInteger

RPushX Inserts specified values at the tail of the list stored at key, only if key already exists and holds a list.

func (*Tx) RandomKey

func (b *Tx) RandomKey() *ReplyBulkString

RandomKey returns a random key

func (*Tx) Rename

func (b *Tx) Rename(key, newkey string) *ReplyOK

Rename renames a key

func (*Tx) RenameNX

func (b *Tx) RenameNX(key, newkey string) *ReplyOK

RenameNX renames a key if the new name does not exist

func (*Tx) Restore

func (b *Tx) Restore(r Restore) *ReplyOK

Restore restores a key value from a string

func (*Tx) Set

func (b *Tx) Set(key, value string, ttl time.Duration) *ReplyOK

Set sets a key to value

func (*Tx) SetEX

func (b *Tx) SetEX(key, value string, ttl time.Duration) *ReplyOK

SetEX sets a key with a ttl

func (*Tx) SetNX

func (b *Tx) SetNX(key, value string, ttl time.Duration) *ReplyOK

SetNX sets a new key value

func (*Tx) SetRange

func (b *Tx) SetRange(key string, offset int64, value string) *ReplyBulkString

SetRange sets a part of a string

func (*Tx) SetXX

func (b *Tx) SetXX(key, value string, ttl time.Duration) *ReplyOK

SetXX resets a key value if it exists

func (*Tx) Sort

func (b *Tx) Sort(key string, sort Sort) *ReplyBulkStringArray

Sort sorts a key's values

func (*Tx) SortStore

func (b *Tx) SortStore(dest, key string, sort Sort) *ReplyInteger

SortStore sorts a `key`'s value storing the result in `dest`

func (*Tx) StrLen

func (b *Tx) StrLen(key string) *ReplyBulkString

StrLen return the length of a string value

func (*Tx) TTL

func (b *Tx) TTL(key string) *ReplyInteger

TTL returns the remaining lifetime of a key in seconds

func (*Tx) Touch

func (b *Tx) Touch(keys ...string) *ReplyInteger

Touch alters the last access time of a key(s).

func (*Tx) Type

func (b *Tx) Type(key string) *ReplySimpleString

Type returns the type of the value of a key

func (b *Tx) Unlink(keys ...string) *ReplyInteger

Unlink drops keys

func (*Tx) Wait

func (b *Tx) Wait(numReplicas int, timeout time.Duration) *ReplyInteger

Wait blocks until a number of replicas have stored the data or timeout occured

func (*Tx) XAck

func (b *Tx) XAck(key, group string, id string, ids ...string) *ReplyInteger

XAck removes one or multiple messages from the pending entries list (PEL) of a stream consumer group. XACK key group ID [ID ...]

func (*Tx) XAdd

func (b *Tx) XAdd(key string, maxLen int64, id string, fields ...HArg) *ReplyBulkString

XAdd appends the specified stream entry to the stream at the specified key.

XADD key ID field value [field value ...]

If the key does not exist, as a side effect of running this command, the key is created with a stream value.

func (*Tx) XDel

func (b *Tx) XDel(key string, ids ...string) *ReplyInteger

XDel deletes entries from a stream

func (*Tx) XGroupCreate

func (b *Tx) XGroupCreate(key, group, id string, makeStream bool) *ReplyOK

XGroupCreate creates a new consumer group associated with a stream. XGROUP [CREATE key groupname id-or-$]

func (*Tx) XGroupDelConsumer

func (b *Tx) XGroupDelConsumer(key, group, consumer string) *ReplyInteger

XGroupDelConsumer removes a specific consumer from a consumer group

func (*Tx) XGroupDestroy

func (b *Tx) XGroupDestroy(key, group string) *ReplyInteger

XGroupDestroy destroys a consumer group

func (*Tx) XGroupSetID

func (b *Tx) XGroupSetID(key, group, id string) *ReplyOK

XGroupSetID sets the consumer group last delivered ID to something else. XGROUP [SETID key groupname id-or-$]

func (*Tx) XInfoConsumers

func (b *Tx) XInfoConsumers(key, group string) *ReplyXInfoConsumers

XInfoConsumers returns the list of every consumer in a specific consumer group

func (*Tx) XInfoGroups

func (b *Tx) XInfoGroups(key string) *ReplyXInfoGroups

XInfoGroups returns all the consumer groups associated with the stream.

func (*Tx) XInfoHelp

func (b *Tx) XInfoHelp() *ReplyBulkStringArray

XInfoHelp gets help for XINFO command

func (*Tx) XInfoStream

func (b *Tx) XInfoStream(key string) *ReplyXInfoStream

XInfoStream returns general information about the stream stored at the specified key.

func (*Tx) XLen

func (b *Tx) XLen(key string) *ReplyInteger

XLen returns the number of entries inside a stream.

func (*Tx) XPending

func (b *Tx) XPending(key, group string) *ReplyXPendingSummary

func (*Tx) XPendingConsumer

func (b *Tx) XPendingConsumer(args XPending) *ReplyXPending

func (*Tx) XPendingGroup

func (b *Tx) XPendingGroup(args XPending) *ReplyXPending

func (*Tx) XRange

func (b *Tx) XRange(key, group, start, end string, count int64) *ReplyXRange

Command implements Commander interface

func (*Tx) XRevRange

func (b *Tx) XRevRange(key, group, end, start string, count int64) *ReplyXRange

func (*Tx) ZAdd

func (b *Tx) ZAdd(key string, mode Mode, members ...ZEntry) *ReplyInteger

ZAdd adds or modifies the a member of a sorted set

func (*Tx) ZAddIncr

func (b *Tx) ZAddIncr(key string, mode Mode, member string, d float64) *ReplyFloat

ZAddIncr increments the score of a sorted set member by d

func (*Tx) ZCard

func (b *Tx) ZCard(key string) *ReplyInteger

ZCard returns the cardinality of a sorted set

func (*Tx) ZCount

func (b *Tx) ZCount(key string, min, max Arg) *ReplyInteger

ZCount returns the number of elements in the sorted set at key with a score between min and max.

func (*Tx) ZIncrBy

func (b *Tx) ZIncrBy(key string, incr float64, member string) *ReplyFloat

ZIncrBy increments the score of member in the sorted set stored at key by increment.

func (*Tx) ZInterStore

func (b *Tx) ZInterStore(args ZStore) *ReplyInteger

ZInterStore computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in destination.

func (*Tx) ZLexCount

func (b *Tx) ZLexCount(key string, min, max Arg) *ReplyInteger

ZLexCount returns the number of elements in the sorted set at key with a value between min and max.

func (*Tx) ZPopMax

func (b *Tx) ZPopMax(key string, count int64) *ReplyZRange

ZPopMax removes and returns up to count members with the highest scores in the sorted set stored at key.

func (*Tx) ZPopMin

func (b *Tx) ZPopMin(key string, count int64) *ReplyZRange

ZPopMin removes and returns up to count members with the lowest scores in the sorted set stored at key.

func (*Tx) ZRange

func (b *Tx) ZRange(key string, start, stop int64) *ReplyBulkStringArray

ZRange returns the specified range of elements in the sorted set stored at key.

func (*Tx) ZRangeByLex

func (b *Tx) ZRangeByLex(key string, min, max Arg, offset, count int64) *ReplyBulkStringArray

ZRangeByLex when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returnWhen all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.s all the elements in the sorted set at key with a value between min and max.

func (*Tx) ZRangeByScore

func (b *Tx) ZRangeByScore(key string, min, max Arg, offset, count int64) *ReplyBulkStringArray

ZRangeByScore returns all the elements in the sorted set at key with a score between min and max

func (*Tx) ZRangeByScoreWithScores

func (b *Tx) ZRangeByScoreWithScores(key string, min, max Arg, offset, count int64) *ReplyZRange

ZRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max

func (*Tx) ZRangeWithScores

func (b *Tx) ZRangeWithScores(key string, start, stop int64) *ReplyZRange

ZRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*Tx) ZRank

func (b *Tx) ZRank(key, member string) *ReplyInteger

ZRank gets the rank of a member of a sorted set ordered from low to high

func (*Tx) ZRem

func (b *Tx) ZRem(key string, members ...string) *ReplyInteger

ZRem removes member(s) from a sorted set

func (*Tx) ZRemRangeByLex

func (b *Tx) ZRemRangeByLex(key string, min, max Arg) *ReplyInteger

ZRemRangeByLex removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.

func (*Tx) ZRemRangeByRank

func (b *Tx) ZRemRangeByRank(key string, start, stop int64) *ReplyInteger

ZRemRangeByRank removes all elements in the sorted set stored at key with rank between start and stop.

func (*Tx) ZRemRangeByScore

func (b *Tx) ZRemRangeByScore(key string, min, max Arg) *ReplyInteger

ZRemRangeByScore removes all elements in the sorted set stored at key with a score between min and max (inclusive).

func (*Tx) ZRevRange

func (b *Tx) ZRevRange(key string, start, stop int64) *ReplyBulkStringArray

ZRevRange returns the specified range of elements in the sorted set stored at key.

func (*Tx) ZRevRangeByLex

func (b *Tx) ZRevRangeByLex(key string, max, min Arg, offset, count int64) *ReplyBulkStringArray

ZRevRangeByLex when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returnWhen all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.s all the elements in the sorted set at key with a value between min and max.

func (*Tx) ZRevRangeByScore

func (b *Tx) ZRevRangeByScore(key string, max, min Arg, offset, count int64) *ReplyBulkStringArray

ZRevRangeByScore returns all the elements in the sorted set at key with a score between min and max

func (*Tx) ZRevRangeByScoreWithScores

func (b *Tx) ZRevRangeByScoreWithScores(key string, max, min Arg, offset, count int64) *ReplyZRange

ZRevRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max

func (*Tx) ZRevRangeWithScores

func (b *Tx) ZRevRangeWithScores(key string, start, stop int64) *ReplyZRange

ZRevRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*Tx) ZRevRank

func (b *Tx) ZRevRank(key, member string) *ReplyInteger

ZRevRank gets the rank of a member of a sorted set ordered from high to low

func (*Tx) ZScore

func (b *Tx) ZScore(key, member string) *ReplyFloat

ZScore returns the score of a member

func (*Tx) ZUnionStore

func (b *Tx) ZUnionStore(args ZStore) *ReplyInteger

ZUnionStore computes the union of numkeys sorted sets given by the specified keys, and stores the result in destination.

type XClaim

type XClaim struct {
	Key         string
	Group       string
	Consumer    string
	MinIdleTime time.Duration
	IDs         []string
	Idle        time.Duration
	RetryCount  int
	Force       bool
	Time        time.Time
	JustID      bool
}

XClaim claims a pending message in a consumer group.

XCLAIM key group consumer min-idle-time ID [ID ...] [IDLE ms] [TIME ms-unix-time] [RETRYCOUNT count] [FORCE] [JUSTID]

Available since 5.0.0.

Time complexity: O(log N) with N being the number of messages in the PEL of the consumer group.

In the context of a stream consumer group, this command changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument. Normally this is what happens:

  1. There is a stream with an associated consumer group.
  2. Some consumer A reads a message via XREADGROUP from a stream, in the context of that consumer group.
  3. As a side effect a pending message entry is created in the pending entries list (PEL) of the consumer group: it means the message was delivered to a given consumer, but it was not yet acknowledged via XACK.
  4. Then suddenly that consumer fails forever.
  5. Other consumers may inspect the list of pending messages, that are stale for quite some time, using the XPENDING command. In order to continue processing such messages, they use XCLAIM to acquire the ownership of the message and continue.

This dynamic is clearly explained in the [Stream intro documentation](https://redis.io/topics/streams-intro).

func (*XClaim) BuildCommand

func (cmd *XClaim) BuildCommand(args *ArgBuilder) string

BuildCommand implements CommandBuilder interface

type XInfoConsumer

type XInfoConsumer struct {
	Name    string
	Pending int64
	Idle    time.Duration
}

func (*XInfoConsumer) UnmarshalRESP

func (info *XInfoConsumer) UnmarshalRESP(v resp.Value) error

type XInfoEntry

type XInfoEntry struct {
	ID     string
	Values map[string]string
}

func (*XInfoEntry) UnmarshalRESP

func (info *XInfoEntry) UnmarshalRESP(v resp.Value) error

type XInfoGroup

type XInfoGroup struct {
	Name      string
	Consumers int64
	Pending   int64
}

func (*XInfoGroup) UnmarshalRESP

func (info *XInfoGroup) UnmarshalRESP(v resp.Value) error

type XInfoStream

type XInfoStream struct {
	Length          int64
	RadixTreeKeys   int64
	RadixTreeNodes  int64
	Groups          int64
	LastGeneratedID resp.BulkString
	FirstEntry      XInfoEntry
	LastEntry       XInfoEntry
}

func (*XInfoStream) UnmarshalRESP

func (info *XInfoStream) UnmarshalRESP(v resp.Value) error

type XPending

type XPending struct {
	Key        string
	Group      string
	Consumer   string
	Start, End string
	Count      int64
}

func (*XPending) BuildCommand

func (cmd *XPending) BuildCommand(args *ArgBuilder) string

BuildCommand implements CommandBuilder interface

type XPendingConsumer

type XPendingConsumer struct {
	Name    string
	Pending int64
}

func (*XPendingConsumer) UnmarshalRESP

func (x *XPendingConsumer) UnmarshalRESP(v resp.Value) error

type XPendingEntry

type XPendingEntry struct {
	ID       string
	Consumer string

	Retries int64
	// contains filtered or unexported fields
}

func (*XPendingEntry) Age

func (x *XPendingEntry) Age() time.Duration

func (*XPendingEntry) UnmarshalRESP

func (x *XPendingEntry) UnmarshalRESP(v resp.Value) error

type XPendingSummary

type XPendingSummary struct {
	Pending   int64
	MinID     string
	MaxID     string
	Consumers []XPendingConsumer
}

func (*XPendingSummary) UnmarshalRESP

func (x *XPendingSummary) UnmarshalRESP(v resp.Value) error

type XRange

type XRange struct {
	Start string
	End   string
	Count int64
}

type XRead

type XRead struct {
	Count    int64
	Group    string
	Consumer string
	NoACK    bool
	Block    time.Duration
	Streams  []XReadStream
}

func (*XRead) BuildCommand

func (cmd *XRead) BuildCommand(args *ArgBuilder) string

BuildCommand implements CommandBuilder interface

type XReadStream

type XReadStream struct {
	Key    string
	LastID string
}

func Stream

func Stream(key, id string) XReadStream

type ZEntry

type ZEntry struct {
	Member string
	Score  float64
}

ZEntry is the entry of a sorted set

func Z

func Z(member string, score float64) ZEntry

Z creates a ZEntry

type ZPop

type ZPop struct {
	Key    string
	Member string
	Score  float64
}

func (*ZPop) UnmarshalRESP

func (z *ZPop) UnmarshalRESP(v resp.Value) error

type ZStore

type ZStore struct {
	Destination string
	Keys        []string
	Weights     map[string]float64
	Aggregate   Aggregate
}

ZStore holds arguments for ZUNIONSTORE and ZINTERSTORE commands

Directories

Path Synopsis
internal
Package resp provides RESP protocol serialization and deserialization
Package resp provides RESP protocol serialization and deserialization

Jump to

Keyboard shortcuts

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