github.com/redis/go-redis/v9
Package redis implements a Redis client.
Package
Files: 35. Third party imports: 2. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Constants
const BitCountIndexBit string = "BIT"
const BitCountIndexByte string = "BYTE"
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
// otherwise you will receive an error: (error) ERR syntax error.
// For example:
//
// rdb.Set(ctx, key, value, redis.KeepTTL)
const KeepTTL = -1
// Nil reply returned by Redis when key does not exist.
const Nil = proto.Nil
// TxFailedErr transaction redis failed.
const TxFailedErr = proto.RedisError("redis: transaction failed")
const (
ClientSlave ClientFlags = 1 << 0 /* This client is a replica */
ClientMaster ClientFlags = 1 << 1 /* This client is a master */
ClientMonitor ClientFlags = 1 << 2 /* This client is a slave monitor, see MONITOR */
ClientMulti ClientFlags = 1 << 3 /* This client is in a MULTI context */
ClientBlocked ClientFlags = 1 << 4 /* The client is waiting in a blocking operation */
ClientDirtyCAS ClientFlags = 1 << 5 /* Watched keys modified. EXEC will fail. */
ClientCloseAfterReply ClientFlags = 1 << 6 /* Close after writing entire reply. */
ClientUnBlocked ClientFlags = 1 << 7 /* This client was unblocked and is stored in server.unblocked_clients */
ClientScript ClientFlags = 1 << 8 /* This is a non-connected client used by Lua */
ClientAsking ClientFlags = 1 << 9 /* Client issued the ASKING command */
ClientCloseASAP ClientFlags = 1 << 10 /* Close this client ASAP */
ClientUnixSocket ClientFlags = 1 << 11 /* Client connected via Unix domain socket */
ClientDirtyExec ClientFlags = 1 << 12 /* EXEC will fail for errors while queueing */
ClientMasterForceReply ClientFlags = 1 << 13 /* Queue replies even if is master */
ClientForceAOF ClientFlags = 1 << 14 /* Force AOF propagation of current cmd. */
ClientForceRepl ClientFlags = 1 << 15 /* Force replication of current cmd. */
ClientPrePSync ClientFlags = 1 << 16 /* Instance don't understand PSYNC. */
ClientReadOnly ClientFlags = 1 << 17 /* Cluster client is in read-only state. */
ClientPubSub ClientFlags = 1 << 18 /* Client is in Pub/Sub mode. */
ClientPreventAOFProp ClientFlags = 1 << 19 /* Don't propagate to AOF. */
ClientPreventReplProp ClientFlags = 1 << 20 /* Don't propagate to slaves. */
ClientPreventProp ClientFlags = ClientPreventAOFProp | ClientPreventReplProp
ClientPendingWrite ClientFlags = 1 << 21 /* Client has output to send but a-write handler is yet not installed. */
ClientReplyOff ClientFlags = 1 << 22 /* Don't send replies to client. */
ClientReplySkipNext ClientFlags = 1 << 23 /* Set ClientREPLY_SKIP for next cmd */
ClientReplySkip ClientFlags = 1 << 24 /* Don't send just this reply. */
ClientLuaDebug ClientFlags = 1 << 25 /* Run EVAL in debug mode. */
ClientLuaDebugSync ClientFlags = 1 << 26 /* EVAL debugging without fork() */
ClientModule ClientFlags = 1 << 27 /* Non connected client used by some module. */
ClientProtected ClientFlags = 1 << 28 /* Client should not be freed for now. */
ClientExecutingCommand ClientFlags = 1 << 29 /* Indicates that the client is currently in the process of handling
a command. usually this will be marked only during call()
however, blocked clients might have this flag kept until they
will try to reprocess the command. */
ClientPendingCommand ClientFlags = 1 << 30 /* Indicates the client has a fully * parsed command ready for execution. */
ClientTracking ClientFlags = 1 << 31 /* Client enabled keys tracking in order to perform client side caching. */
ClientTrackingBrokenRedir ClientFlags = 1 << 32 /* Target client is invalid. */
ClientTrackingBCAST ClientFlags = 1 << 33 /* Tracking in BCAST mode. */
ClientTrackingOptIn ClientFlags = 1 << 34 /* Tracking in opt-in mode. */
ClientTrackingOptOut ClientFlags = 1 << 35 /* Tracking in opt-out mode. */
ClientTrackingCaching ClientFlags = 1 << 36 /* CACHING yes/no was given, depending on optin/optout mode. */
ClientTrackingNoLoop ClientFlags = 1 << 37 /* Don't send invalidation messages about writes performed by myself.*/
ClientInTimeoutTable ClientFlags = 1 << 38 /* This client is in the timeout table. */
ClientProtocolError ClientFlags = 1 << 39 /* Protocol error chatting with it. */
ClientCloseAfterCommand ClientFlags = 1 << 40 /* Close after executing commands * and writing entire reply. */
ClientDenyBlocking ClientFlags = 1 << 41 /* Indicate that the client should not be blocked. currently, turned on inside MULTI, Lua, RM_Call, and AOF client */
ClientReplRDBOnly ClientFlags = 1 << 42 /* This client is a replica that only wants RDB without replication buffer. */
ClientNoEvict ClientFlags = 1 << 43 /* This client is protected against client memory eviction. */
ClientAllowOOM ClientFlags = 1 << 44 /* Client used by RM_Call is allowed to fully execute scripts even when in OOM */
ClientNoTouch ClientFlags = 1 << 45 /* This client will not touch LFU/LRU stats. */
ClientPushing ClientFlags = 1 << 46 /* This client is pushing notifications. */
)
const (
monitorStatusIdle MonitorStatus = iota
monitorStatusStart
monitorStatusStop
)
const (
SearchInvalid = SearchAggregator(iota)
SearchAvg
SearchSum
SearchMin
SearchMax
SearchCount
SearchCountDistinct
SearchCountDistinctish
SearchStdDev
SearchQuantile
SearchToList
SearchFirstValue
SearchRandomSample
)
const (
SearchFieldTypeInvalid = SearchFieldType(iota)
SearchFieldTypeNumeric
SearchFieldTypeTag
SearchFieldTypeText
SearchFieldTypeGeo
SearchFieldTypeVector
SearchFieldTypeGeoShape
)
const (
Invalid = Aggregator(iota)
Avg
Sum
Min
Max
Range
Count
First
Last
StdP
StdS
VarP
VarS
Twa
)
const maximumNodeLatency = 1 * time.Minute
const (
minLatencyMeasurementInterval = 10 * time.Second
)
Vars
ErrClosed performs any operation on the closed client will return this error.
var ErrClosed = pool.ErrClosed
var _ Cmder = (*Cmd)(nil)
var errClusterNoNodes = fmt.Errorf("redis: cluster has no nodes")
var errRingShardsDown = errors.New("redis: all ring shards are down")
Types
ACLCmdable
This type doesn't have documentation.
type ACLCmdable interface {
ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
ACLLog(ctx context.Context, count int64) *ACLLogCmd
ACLLogReset(ctx context.Context) *StatusCmd
}
ACLLogCmd
This type doesn't have documentation.
type ACLLogCmd struct {
baseCmd
val []*ACLLogEntry
}
ACLLogEntry
This type doesn't have documentation.
type ACLLogEntry struct {
Count int64
Reason string
Context string
Object string
Username string
AgeSeconds float64
ClientInfo *ClientInfo
EntryID int64
TimestampCreated int64
TimestampLastUpdated int64
}
AggregateCmd
This type doesn't have documentation.
type AggregateCmd struct {
baseCmd
val *FTAggregateResult
}
AggregateQuery
This type doesn't have documentation.
type AggregateQuery []interface{}
AggregateRow
This type doesn't have documentation.
type AggregateRow struct {
Fields map[string]interface{}
}
Aggregator
This type doesn't have documentation.
type Aggregator int
BFInfo
This type doesn't have documentation.
type BFInfo struct {
Capacity int64
Size int64
Filters int64
ItemsInserted int64
ExpansionRate int64
}
BFInfoCmd
This type doesn't have documentation.
type BFInfoCmd struct {
baseCmd
val BFInfo
}
BFInsertOptions
This type doesn't have documentation.
type BFInsertOptions struct {
Capacity int64
Error float64
Expansion int64
NonScaling bool
NoCreate bool
}
BFReserveOptions
This type doesn't have documentation.
type BFReserveOptions struct {
Capacity int64
Error float64
Expansion int64
NonScaling bool
}
BitCount
This type doesn't have documentation.
type BitCount struct {
Start, End int64
Unit string // BYTE(default) | BIT
}
BitMapCmdable
This type doesn't have documentation.
type BitMapCmdable interface {
GetBit(ctx context.Context, key string, offset int64) *IntCmd
SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd
BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd
BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd
BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd
BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd
BitOpNot(ctx context.Context, destKey string, key string) *IntCmd
BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd
BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd
BitFieldRO(ctx context.Context, key string, values ...interface{}) *IntSliceCmd
}
BoolCmd
This type doesn't have documentation.
type BoolCmd struct {
baseCmd
val bool
}
BoolSliceCmd
This type doesn't have documentation.
type BoolSliceCmd struct {
baseCmd
val []bool
}
CFInfo
This type doesn't have documentation.
type CFInfo struct {
Size int64
NumBuckets int64
NumFilters int64
NumItemsInserted int64
NumItemsDeleted int64
BucketSize int64
ExpansionRate int64
MaxIteration int64
}
CFInfoCmd
This type doesn't have documentation.
type CFInfoCmd struct {
baseCmd
val CFInfo
}
CFInsertOptions
This type doesn't have documentation.
type CFInsertOptions struct {
Capacity int64
NoCreate bool
}
CFReserveOptions
This type doesn't have documentation.
type CFReserveOptions struct {
Capacity int64
BucketSize int64
MaxIterations int64
Expansion int64
}
CMSInfo
This type doesn't have documentation.
type CMSInfo struct {
Width int64
Depth int64
Count int64
}
CMSInfoCmd
This type doesn't have documentation.
type CMSInfoCmd struct {
baseCmd
val CMSInfo
}
ChannelOption
This type doesn't have documentation.
type ChannelOption func(c *channel)
Client
Client is a Redis client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.
Client creates and frees connections automatically; it also maintains a free pool of idle connections. You can control the pool size with Config.PoolSize option.
type Client struct {
*baseClient
cmdable
hooksMixin
}
ClientFlags
ClientFlags is redis-server client flags, copy from redis/src/server.h (redis 7.0)
type ClientFlags uint64
ClientInfo
ClientInfo is redis-server ClientInfo, not go-redis *Client
type ClientInfo struct {
ID int64 // redis version 2.8.12, a unique 64-bit client ID
Addr string // address/port of the client
LAddr string // address/port of local address client connected to (bind address)
FD int64 // file descriptor corresponding to the socket
Name string // the name set by the client with CLIENT SETNAME
Age time.Duration // total duration of the connection in seconds
Idle time.Duration // idle time of the connection in seconds
Flags ClientFlags // client flags (see below)
DB int // current database ID
Sub int // number of channel subscriptions
PSub int // number of pattern matching subscriptions
SSub int // redis version 7.0.3, number of shard channel subscriptions
Multi int // number of commands in a MULTI/EXEC context
Watch int // redis version 7.4 RC1, number of keys this client is currently watching.
QueryBuf int // qbuf, query buffer length (0 means no query pending)
QueryBufFree int // qbuf-free, free space of the query buffer (0 means the buffer is full)
ArgvMem int // incomplete arguments for the next command (already extracted from query buffer)
MultiMem int // redis version 7.0, memory is used up by buffered multi commands
BufferSize int // rbs, usable size of buffer
BufferPeak int // rbp, peak used size of buffer in last 5 sec interval
OutputBufferLength int // obl, output buffer length
OutputListLength int // oll, output list length (replies are queued in this list when the buffer is full)
OutputMemory int // omem, output buffer memory usage
TotalMemory int // tot-mem, total memory consumed by this client in its various buffers
Events string // file descriptor events (see below)
LastCmd string // cmd, last command played
User string // the authenticated username of the client
Redir int64 // client id of current client tracking redirection
Resp int // redis version 7.0, client RESP protocol version
LibName string // redis version 7.2, client library name
LibVer string // redis version 7.2, client library version
}
ClientInfoCmd
This type doesn't have documentation.
type ClientInfoCmd struct {
baseCmd
val *ClientInfo
}
ClusterClient
ClusterClient is a Redis Cluster client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.
type ClusterClient struct {
opt *ClusterOptions
nodes *clusterNodes
state *clusterStateHolder
cmdsInfoCache *cmdsInfoCache
cmdable
hooksMixin
}
ClusterCmdable
This type doesn't have documentation.
type ClusterCmdable interface {
ClusterMyShardID(ctx context.Context) *StringCmd
ClusterSlots(ctx context.Context) *ClusterSlotsCmd
ClusterShards(ctx context.Context) *ClusterShardsCmd
ClusterLinks(ctx context.Context) *ClusterLinksCmd
ClusterNodes(ctx context.Context) *StringCmd
ClusterMeet(ctx context.Context, host, port string) *StatusCmd
ClusterForget(ctx context.Context, nodeID string) *StatusCmd
ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd
ClusterResetSoft(ctx context.Context) *StatusCmd
ClusterResetHard(ctx context.Context) *StatusCmd
ClusterInfo(ctx context.Context) *StringCmd
ClusterKeySlot(ctx context.Context, key string) *IntCmd
ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd
ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd
ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd
ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd
ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd
ClusterSaveConfig(ctx context.Context) *StatusCmd
ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd
ClusterFailover(ctx context.Context) *StatusCmd
ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd
ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd
ReadOnly(ctx context.Context) *StatusCmd
ReadWrite(ctx context.Context) *StatusCmd
}
ClusterLink
This type doesn't have documentation.
type ClusterLink struct {
Direction string
Node string
CreateTime int64
Events string
SendBufferAllocated int64
SendBufferUsed int64
}
ClusterLinksCmd
This type doesn't have documentation.
type ClusterLinksCmd struct {
baseCmd
val []ClusterLink
}
ClusterNode
This type doesn't have documentation.
type ClusterNode struct {
ID string
Addr string
NetworkingMetadata map[string]string
}
ClusterOptions
ClusterOptions are used to configure a cluster client and should be passed to NewClusterClient.
type ClusterOptions struct {
// A seed list of host:port addresses of cluster nodes.
Addrs []string
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
ClientName string
// NewClient creates a cluster node client with provided name and options.
NewClient func(opt *Options) *Client
// The maximum number of retries before giving up. Command is retried
// on network errors and MOVED/ASK redirects.
// Default is 3 retries.
MaxRedirects int
// Enables read-only commands on slave nodes.
ReadOnly bool
// Allows routing read-only commands to the closest master or slave node.
// It automatically enables ReadOnly.
RouteByLatency bool
// Allows routing read-only commands to the random master or slave node.
// It automatically enables ReadOnly.
RouteRandomly bool
// Optional function that returns cluster slots information.
// It is useful to manually create cluster of standalone Redis servers
// and load-balance read/write operations between master and slaves.
// It can use service like ZooKeeper to maintain configuration information
// and Cluster.ReloadState to manually trigger state reloading.
ClusterSlots func(context.Context) ([]ClusterSlot, error)
// Following options are copied from Options struct.
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error
Protocol int
Username string
Password string
CredentialsProvider func() (username string, password string)
CredentialsProviderContext func(ctx context.Context) (username string, password string, err error)
MaxRetries int
MinRetryBackoff time.Duration
MaxRetryBackoff time.Duration
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
ContextTimeoutEnabled bool
PoolFIFO bool
PoolSize int // applies per cluster node and not for the whole cluster
PoolTimeout time.Duration
MinIdleConns int
MaxIdleConns int
MaxActiveConns int // applies per cluster node and not for the whole cluster
ConnMaxIdleTime time.Duration
ConnMaxLifetime time.Duration
TLSConfig *tls.Config
DisableIndentity bool // Disable set-lib on connect. Default is false.
IdentitySuffix string // Add suffix to client name. Default is empty.
}
ClusterShard
This type doesn't have documentation.
type ClusterShard struct {
Slots []SlotRange
Nodes []Node
}
ClusterShardsCmd
This type doesn't have documentation.
type ClusterShardsCmd struct {
baseCmd
val []ClusterShard
}
ClusterSlot
This type doesn't have documentation.
type ClusterSlot struct {
Start int
End int
Nodes []ClusterNode
}
ClusterSlotsCmd
This type doesn't have documentation.
type ClusterSlotsCmd struct {
baseCmd
val []ClusterSlot
}
Cmd
This type doesn't have documentation.
type Cmd struct {
baseCmd
val interface{}
}
Cmdable
This type doesn't have documentation.
type Cmdable interface {
Pipeline() Pipeliner
Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
TxPipeline() Pipeliner
Command(ctx context.Context) *CommandsInfoCmd
CommandList(ctx context.Context, filter *FilterBy) *StringSliceCmd
CommandGetKeys(ctx context.Context, commands ...interface{}) *StringSliceCmd
CommandGetKeysAndFlags(ctx context.Context, commands ...interface{}) *KeyFlagsCmd
ClientGetName(ctx context.Context) *StringCmd
Echo(ctx context.Context, message interface{}) *StringCmd
Ping(ctx context.Context) *StatusCmd
Quit(ctx context.Context) *StatusCmd
Unlink(ctx context.Context, keys ...string) *IntCmd
BgRewriteAOF(ctx context.Context) *StatusCmd
BgSave(ctx context.Context) *StatusCmd
ClientKill(ctx context.Context, ipPort string) *StatusCmd
ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd
ClientList(ctx context.Context) *StringCmd
ClientInfo(ctx context.Context) *ClientInfoCmd
ClientPause(ctx context.Context, dur time.Duration) *BoolCmd
ClientUnpause(ctx context.Context) *BoolCmd
ClientID(ctx context.Context) *IntCmd
ClientUnblock(ctx context.Context, id int64) *IntCmd
ClientUnblockWithError(ctx context.Context, id int64) *IntCmd
ConfigGet(ctx context.Context, parameter string) *MapStringStringCmd
ConfigResetStat(ctx context.Context) *StatusCmd
ConfigSet(ctx context.Context, parameter, value string) *StatusCmd
ConfigRewrite(ctx context.Context) *StatusCmd
DBSize(ctx context.Context) *IntCmd
FlushAll(ctx context.Context) *StatusCmd
FlushAllAsync(ctx context.Context) *StatusCmd
FlushDB(ctx context.Context) *StatusCmd
FlushDBAsync(ctx context.Context) *StatusCmd
Info(ctx context.Context, section ...string) *StringCmd
LastSave(ctx context.Context) *IntCmd
Save(ctx context.Context) *StatusCmd
Shutdown(ctx context.Context) *StatusCmd
ShutdownSave(ctx context.Context) *StatusCmd
ShutdownNoSave(ctx context.Context) *StatusCmd
SlaveOf(ctx context.Context, host, port string) *StatusCmd
SlowLogGet(ctx context.Context, num int64) *SlowLogCmd
Time(ctx context.Context) *TimeCmd
DebugObject(ctx context.Context, key string) *StringCmd
MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd
ModuleLoadex(ctx context.Context, conf *ModuleLoadexConfig) *StringCmd
ACLCmdable
BitMapCmdable
ClusterCmdable
GearsCmdable
GenericCmdable
GeoCmdable
HashCmdable
HyperLogLogCmdable
ListCmdable
ProbabilisticCmdable
PubSubCmdable
ScriptingFunctionsCmdable
SearchCmdable
SetCmdable
SortedSetCmdable
StringCmdable
StreamCmdable
TimeseriesCmdable
JSONCmdable
}
Cmder
This type doesn't have documentation.
type Cmder interface {
// command name.
// e.g. "set k v ex 10" -> "set", "cluster info" -> "cluster".
Name() string
// full command name.
// e.g. "set k v ex 10" -> "set", "cluster info" -> "cluster info".
FullName() string
// all args of the command.
// e.g. "set k v ex 10" -> "[set k v ex 10]".
Args() []interface{}
// format request and response string.
// e.g. "set k v ex 10" -> "set k v ex 10: OK", "get k" -> "get k: v".
String() string
stringArg(int) string
firstKeyPos() int8
SetFirstKeyPos(int8)
readTimeout() *time.Duration
readReply(rd *proto.Reader) error
readRawReply(rd *proto.Reader) error
SetErr(error)
Err() error
}
CommandInfo
This type doesn't have documentation.
type CommandInfo struct {
Name string
Arity int8
Flags []string
ACLFlags []string
FirstKeyPos int8
LastKeyPos int8
StepCount int8
ReadOnly bool
}
CommandsInfoCmd
This type doesn't have documentation.
type CommandsInfoCmd struct {
baseCmd
val map[string]*CommandInfo
}
Conn
Conn represents a single Redis connection rather than a pool of connections. Prefer running commands from Client unless there is a specific need for a continuous single Redis connection.
type Conn struct {
baseClient
cmdable
statefulCmdable
hooksMixin
}
ConsistentHash
This type doesn't have documentation.
type ConsistentHash interface {
Get(string) string
}
CursorStats
This type doesn't have documentation.
type CursorStats struct {
GlobalIdle int
GlobalTotal int
IndexCapacity int
IndexTotal int
}
Document
This type doesn't have documentation.
type Document struct {
ID string
Score *float64
Payload *string
SortKey *string
Fields map[string]string
}
DurationCmd
This type doesn't have documentation.
type DurationCmd struct {
baseCmd
val time.Duration
precision time.Duration
}
Engine
This type doesn't have documentation.
type Engine struct {
Language string
LibrariesCount int64
FunctionsCount int64
}
Error
This type doesn't have documentation.
type Error interface {
error
// RedisError is a no-op function but
// serves to distinguish types that are Redis
// errors from ordinary errors: a type is a
// Redis error if it has a RedisError method.
RedisError()
}
FTAggregateApply
This type doesn't have documentation.
type FTAggregateApply struct {
Field string
As string
}
FTAggregateGroupBy
This type doesn't have documentation.
type FTAggregateGroupBy struct {
Fields []interface{}
Reduce []FTAggregateReducer
}
FTAggregateLoad
This type doesn't have documentation.
type FTAggregateLoad struct {
Field string
As string
}
FTAggregateOptions
This type doesn't have documentation.
type FTAggregateOptions struct {
Verbatim bool
LoadAll bool
Load []FTAggregateLoad
Timeout int
GroupBy []FTAggregateGroupBy
SortBy []FTAggregateSortBy
SortByMax int
Apply []FTAggregateApply
LimitOffset int
Limit int
Filter string
WithCursor bool
WithCursorOptions *FTAggregateWithCursor
Params map[string]interface{}
DialectVersion int
}
FTAggregateReducer
Each AggregateReducer have different args. Please follow https://redis.io/docs/interact/search-and-query/search/aggregations/#supported-groupby-reducers for more information.
type FTAggregateReducer struct {
Reducer SearchAggregator
Args []interface{}
As string
}
FTAggregateResult
This type doesn't have documentation.
type FTAggregateResult struct {
Total int
Rows []AggregateRow
}
FTAggregateSortBy
This type doesn't have documentation.
type FTAggregateSortBy struct {
FieldName string
Asc bool
Desc bool
}
FTAggregateWithCursor
This type doesn't have documentation.
type FTAggregateWithCursor struct {
Count int
MaxIdle int
}
FTAttribute
This type doesn't have documentation.
type FTAttribute struct {
Identifier string
Attribute string
Type string
Weight float64
Sortable bool
NoStem bool
NoIndex bool
UNF bool
PhoneticMatcher string
CaseSensitive bool
WithSuffixtrie bool
}
FTCreateOptions
This type doesn't have documentation.
type FTCreateOptions struct {
OnHash bool
OnJSON bool
Prefix []interface{}
Filter string
DefaultLanguage string
LanguageField string
Score float64
ScoreField string
PayloadField string
MaxTextFields int
NoOffsets bool
Temporary int
NoHL bool
NoFields bool
NoFreqs bool
StopWords []interface{}
SkipInitialScan bool
}
FTDropIndexOptions
This type doesn't have documentation.
type FTDropIndexOptions struct {
DeleteDocs bool
}
FTExplainOptions
This type doesn't have documentation.
type FTExplainOptions struct {
Dialect string
}
FTFlatOptions
This type doesn't have documentation.
type FTFlatOptions struct {
Type string
Dim int
DistanceMetric string
InitialCapacity int
BlockSize int
}
FTHNSWOptions
This type doesn't have documentation.
type FTHNSWOptions struct {
Type string
Dim int
DistanceMetric string
InitialCapacity int
MaxEdgesPerNode int
MaxAllowedEdgesPerNode int
EFRunTime int
Epsilon float64
}
FTInfoCmd
This type doesn't have documentation.
type FTInfoCmd struct {
baseCmd
val FTInfoResult
}
FTInfoResult
This type doesn't have documentation.
type FTInfoResult struct {
IndexErrors IndexErrors
Attributes []FTAttribute
BytesPerRecordAvg string
Cleaning int
CursorStats CursorStats
DialectStats map[string]int
DocTableSizeMB float64
FieldStatistics []FieldStatistic
GCStats GCStats
GeoshapesSzMB float64
HashIndexingFailures int
IndexDefinition IndexDefinition
IndexName string
IndexOptions []string
Indexing int
InvertedSzMB float64
KeyTableSizeMB float64
MaxDocID int
NumDocs int
NumRecords int
NumTerms int
NumberOfUses int
OffsetBitsPerRecordAvg string
OffsetVectorsSzMB float64
OffsetsPerTermAvg string
PercentIndexed float64
RecordsPerDocAvg string
SortableValuesSizeMB float64
TagOverheadSzMB float64
TextOverheadSzMB float64
TotalIndexMemorySzMB float64
TotalIndexingTime int
TotalInvertedIndexBlocks int
VectorIndexSzMB float64
}
FTSearchCmd
This type doesn't have documentation.
type FTSearchCmd struct {
baseCmd
val FTSearchResult
options *FTSearchOptions
}
FTSearchFilter
This type doesn't have documentation.
type FTSearchFilter struct {
FieldName interface{}
Min interface{}
Max interface{}
}
FTSearchGeoFilter
This type doesn't have documentation.
type FTSearchGeoFilter struct {
FieldName string
Longitude float64
Latitude float64
Radius float64
Unit string
}
FTSearchOptions
This type doesn't have documentation.
type FTSearchOptions struct {
NoContent bool
Verbatim bool
NoStopWords bool
WithScores bool
WithPayloads bool
WithSortKeys bool
Filters []FTSearchFilter
GeoFilter []FTSearchGeoFilter
InKeys []interface{}
InFields []interface{}
Return []FTSearchReturn
Slop int
Timeout int
InOrder bool
Language string
Expander string
Scorer string
ExplainScore bool
Payload string
SortBy []FTSearchSortBy
SortByWithCount bool
LimitOffset int
Limit int
Params map[string]interface{}
DialectVersion int
}
FTSearchResult
This type doesn't have documentation.
type FTSearchResult struct {
Total int
Docs []Document
}
FTSearchReturn
This type doesn't have documentation.
type FTSearchReturn struct {
FieldName string
As string
}
FTSearchSortBy
This type doesn't have documentation.
type FTSearchSortBy struct {
FieldName string
Asc bool
Desc bool
}
FTSpellCheckCmd
This type doesn't have documentation.
type FTSpellCheckCmd struct {
baseCmd
val []SpellCheckResult
}
FTSpellCheckOptions
This type doesn't have documentation.
type FTSpellCheckOptions struct {
Distance int
Terms *FTSpellCheckTerms
Dialect int
}
FTSpellCheckTerms
This type doesn't have documentation.
type FTSpellCheckTerms struct {
Inclusion string // Either "INCLUDE" or "EXCLUDE"
Dictionary string
Terms []interface{}
}
FTSynDumpCmd
This type doesn't have documentation.
type FTSynDumpCmd struct {
baseCmd
val []FTSynDumpResult
}
FTSynDumpResult
This type doesn't have documentation.
type FTSynDumpResult struct {
Term string
Synonyms []string
}
FTSynUpdateOptions
This type doesn't have documentation.
type FTSynUpdateOptions struct {
SkipInitialScan bool
}
FTVectorArgs
This type doesn't have documentation.
type FTVectorArgs struct {
FlatOptions *FTFlatOptions
HNSWOptions *FTHNSWOptions
}
FailoverOptions
FailoverOptions are used to configure a failover client and should be passed to NewFailoverClient.
type FailoverOptions struct {
// The master name.
MasterName string
// A seed list of host:port addresses of sentinel nodes.
SentinelAddrs []string
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
ClientName string
// If specified with SentinelPassword, enables ACL-based authentication (via
// AUTH <user> <pass>).
SentinelUsername string
// Sentinel password from "requirepass <password>" (if enabled) in Sentinel
// configuration, or, if SentinelUsername is also supplied, used for ACL-based
// authentication.
SentinelPassword string
// Allows routing read-only commands to the closest master or replica node.
// This option only works with NewFailoverClusterClient.
RouteByLatency bool
// Allows routing read-only commands to the random master or replica node.
// This option only works with NewFailoverClusterClient.
RouteRandomly bool
// Route all commands to replica read-only nodes.
ReplicaOnly bool
// Use replicas disconnected with master when cannot get connected replicas
// Now, this option only works in RandomReplicaAddr function.
UseDisconnectedReplicas bool
// Following options are copied from Options struct.
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error
Protocol int
Username string
Password string
DB int
MaxRetries int
MinRetryBackoff time.Duration
MaxRetryBackoff time.Duration
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
ContextTimeoutEnabled bool
PoolFIFO bool
PoolSize int
PoolTimeout time.Duration
MinIdleConns int
MaxIdleConns int
MaxActiveConns int
ConnMaxIdleTime time.Duration
ConnMaxLifetime time.Duration
TLSConfig *tls.Config
DisableIndentity bool
IdentitySuffix string
UnstableResp3 bool
}
FieldSchema
This type doesn't have documentation.
type FieldSchema struct {
FieldName string
As string
FieldType SearchFieldType
Sortable bool
UNF bool
NoStem bool
NoIndex bool
PhoneticMatcher string
Weight float64
Separator string
CaseSensitive bool
WithSuffixtrie bool
VectorArgs *FTVectorArgs
GeoShapeFieldType string
IndexEmpty bool
IndexMissing bool
}
FieldStatistic
This type doesn't have documentation.
type FieldStatistic struct {
Identifier string
Attribute string
IndexErrors IndexErrors
}
FilterBy
FilterBy is used for the CommandList
command parameter.
type FilterBy struct {
Module string
ACLCat string
Pattern string
}
FloatCmd
This type doesn't have documentation.
type FloatCmd struct {
baseCmd
val float64
}
FloatSliceCmd
This type doesn't have documentation.
type FloatSliceCmd struct {
baseCmd
val []float64
}
Function
This type doesn't have documentation.
type Function struct {
Name string
Description string
Flags []string
}
FunctionListCmd
This type doesn't have documentation.
type FunctionListCmd struct {
baseCmd
val []Library
}
FunctionListQuery
FunctionListQuery is used with FunctionList to query for Redis libraries
LibraryNamePattern - Use an empty string to get all libraries.
- Use a glob-style pattern to match multiple libraries with a matching name
- Use a library's full name to match a single library
WithCode - If true, it will return the code of the library
type FunctionListQuery struct {
LibraryNamePattern string
WithCode bool
}
FunctionStats
FunctionStats contains information about the scripts currently executing on the server, and the available engines
- Engines: Statistics about the engine like number of functions and number of libraries
- RunningScript: The script currently running on the shard we're connecting to. For Redis Enterprise and Redis Cloud, this represents the function with the longest running time, across all the running functions, on all shards
- RunningScripts All scripts currently running in a Redis Enterprise clustered database. Only available on Redis Enterprise
type FunctionStats struct {
Engines []Engine
isRunning bool
rs RunningScript
allrs []RunningScript
}
FunctionStatsCmd
This type doesn't have documentation.
type FunctionStatsCmd struct {
baseCmd
val FunctionStats
}
GCStats
This type doesn't have documentation.
type GCStats struct {
BytesCollected int
TotalMsRun int
TotalCycles int
AverageCycleTimeMs string
LastRunTimeMs int
GCNumericTreesMissed int
GCBlocksDenied int
}
GearsCmdable
This type doesn't have documentation.
type GearsCmdable interface {
TFunctionLoad(ctx context.Context, lib string) *StatusCmd
TFunctionLoadArgs(ctx context.Context, lib string, options *TFunctionLoadOptions) *StatusCmd
TFunctionDelete(ctx context.Context, libName string) *StatusCmd
TFunctionList(ctx context.Context) *MapStringInterfaceSliceCmd
TFunctionListArgs(ctx context.Context, options *TFunctionListOptions) *MapStringInterfaceSliceCmd
TFCall(ctx context.Context, libName string, funcName string, numKeys int) *Cmd
TFCallArgs(ctx context.Context, libName string, funcName string, numKeys int, options *TFCallOptions) *Cmd
TFCallASYNC(ctx context.Context, libName string, funcName string, numKeys int) *Cmd
TFCallASYNCArgs(ctx context.Context, libName string, funcName string, numKeys int, options *TFCallOptions) *Cmd
}
GenericCmdable
This type doesn't have documentation.
type GenericCmdable interface {
Del(ctx context.Context, keys ...string) *IntCmd
Dump(ctx context.Context, key string) *StringCmd
Exists(ctx context.Context, keys ...string) *IntCmd
Expire(ctx context.Context, key string, expiration time.Duration) *BoolCmd
ExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd
ExpireTime(ctx context.Context, key string) *DurationCmd
ExpireNX(ctx context.Context, key string, expiration time.Duration) *BoolCmd
ExpireXX(ctx context.Context, key string, expiration time.Duration) *BoolCmd
ExpireGT(ctx context.Context, key string, expiration time.Duration) *BoolCmd
ExpireLT(ctx context.Context, key string, expiration time.Duration) *BoolCmd
Keys(ctx context.Context, pattern string) *StringSliceCmd
Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd
Move(ctx context.Context, key string, db int) *BoolCmd
ObjectFreq(ctx context.Context, key string) *IntCmd
ObjectRefCount(ctx context.Context, key string) *IntCmd
ObjectEncoding(ctx context.Context, key string) *StringCmd
ObjectIdleTime(ctx context.Context, key string) *DurationCmd
Persist(ctx context.Context, key string) *BoolCmd
PExpire(ctx context.Context, key string, expiration time.Duration) *BoolCmd
PExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd
PExpireTime(ctx context.Context, key string) *DurationCmd
PTTL(ctx context.Context, key string) *DurationCmd
RandomKey(ctx context.Context) *StringCmd
Rename(ctx context.Context, key, newkey string) *StatusCmd
RenameNX(ctx context.Context, key, newkey string) *BoolCmd
Restore(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd
RestoreReplace(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd
Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd
SortRO(ctx context.Context, key string, sort *Sort) *StringSliceCmd
SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd
SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd
Touch(ctx context.Context, keys ...string) *IntCmd
TTL(ctx context.Context, key string) *DurationCmd
Type(ctx context.Context, key string) *StatusCmd
Copy(ctx context.Context, sourceKey string, destKey string, db int, replace bool) *IntCmd
Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd
ScanType(ctx context.Context, cursor uint64, match string, count int64, keyType string) *ScanCmd
}
GeoCmdable
This type doesn't have documentation.
type GeoCmdable interface {
GeoAdd(ctx context.Context, key string, geoLocation ...*GeoLocation) *IntCmd
GeoPos(ctx context.Context, key string, members ...string) *GeoPosCmd
GeoRadius(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd
GeoRadiusStore(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *IntCmd
GeoRadiusByMember(ctx context.Context, key, member string, query *GeoRadiusQuery) *GeoLocationCmd
GeoRadiusByMemberStore(ctx context.Context, key, member string, query *GeoRadiusQuery) *IntCmd
GeoSearch(ctx context.Context, key string, q *GeoSearchQuery) *StringSliceCmd
GeoSearchLocation(ctx context.Context, key string, q *GeoSearchLocationQuery) *GeoSearchLocationCmd
GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd
GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd
GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd
}
GeoLocation
GeoLocation is used with GeoAdd to add geospatial location.
type GeoLocation struct {
Name string
Longitude, Latitude, Dist float64
GeoHash int64
}
GeoLocationCmd
This type doesn't have documentation.
type GeoLocationCmd struct {
baseCmd
q *GeoRadiusQuery
locations []GeoLocation
}
GeoPos
This type doesn't have documentation.
type GeoPos struct {
Longitude, Latitude float64
}
GeoPosCmd
This type doesn't have documentation.
type GeoPosCmd struct {
baseCmd
val []*GeoPos
}
GeoRadiusQuery
GeoRadiusQuery is used with GeoRadius to query geospatial index.
type GeoRadiusQuery struct {
Radius float64
// Can be m, km, ft, or mi. Default is km.
Unit string
WithCoord bool
WithDist bool
WithGeoHash bool
Count int
// Can be ASC or DESC. Default is no sort order.
Sort string
Store string
StoreDist string
// WithCoord+WithDist+WithGeoHash
withLen int
}
GeoSearchLocationCmd
This type doesn't have documentation.
type GeoSearchLocationCmd struct {
baseCmd
opt *GeoSearchLocationQuery
val []GeoLocation
}
GeoSearchLocationQuery
This type doesn't have documentation.
type GeoSearchLocationQuery struct {
GeoSearchQuery
WithCoord bool
WithDist bool
WithHash bool
}
GeoSearchQuery
GeoSearchQuery is used for GEOSearch/GEOSearchStore command query.
type GeoSearchQuery struct {
Member string
// Latitude and Longitude when using FromLonLat option.
Longitude float64
Latitude float64
// Distance and unit when using ByRadius option.
// Can use m, km, ft, or mi. Default is km.
Radius float64
RadiusUnit string
// Height, width and unit when using ByBox option.
// Can be m, km, ft, or mi. Default is km.
BoxWidth float64
BoxHeight float64
BoxUnit string
// Can be ASC or DESC. Default is no sort order.
Sort string
Count int
CountAny bool
}
GeoSearchStoreQuery
This type doesn't have documentation.
type GeoSearchStoreQuery struct {
GeoSearchQuery
// When using the StoreDist option, the command stores the items in a
// sorted set populated with their distance from the center of the circle or box,
// as a floating-point number, in the same unit specified for that shape.
StoreDist bool
}
HExpireArgs
This type doesn't have documentation.
type HExpireArgs struct {
NX bool
XX bool
GT bool
LT bool
}
HashCmdable
This type doesn't have documentation.
type HashCmdable interface {
HDel(ctx context.Context, key string, fields ...string) *IntCmd
HExists(ctx context.Context, key, field string) *BoolCmd
HGet(ctx context.Context, key, field string) *StringCmd
HGetAll(ctx context.Context, key string) *MapStringStringCmd
HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd
HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd
HKeys(ctx context.Context, key string) *StringSliceCmd
HLen(ctx context.Context, key string) *IntCmd
HMGet(ctx context.Context, key string, fields ...string) *SliceCmd
HSet(ctx context.Context, key string, values ...interface{}) *IntCmd
HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd
HSetNX(ctx context.Context, key, field string, value interface{}) *BoolCmd
HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
HScanNoValues(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
HVals(ctx context.Context, key string) *StringSliceCmd
HRandField(ctx context.Context, key string, count int) *StringSliceCmd
HRandFieldWithValues(ctx context.Context, key string, count int) *KeyValueSliceCmd
HExpire(ctx context.Context, key string, expiration time.Duration, fields ...string) *IntSliceCmd
HExpireWithArgs(ctx context.Context, key string, expiration time.Duration, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd
HPExpire(ctx context.Context, key string, expiration time.Duration, fields ...string) *IntSliceCmd
HPExpireWithArgs(ctx context.Context, key string, expiration time.Duration, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd
HExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) *IntSliceCmd
HExpireAtWithArgs(ctx context.Context, key string, tm time.Time, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd
HPExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) *IntSliceCmd
HPExpireAtWithArgs(ctx context.Context, key string, tm time.Time, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd
HPersist(ctx context.Context, key string, fields ...string) *IntSliceCmd
HExpireTime(ctx context.Context, key string, fields ...string) *IntSliceCmd
HPExpireTime(ctx context.Context, key string, fields ...string) *IntSliceCmd
HTTL(ctx context.Context, key string, fields ...string) *IntSliceCmd
HPTTL(ctx context.Context, key string, fields ...string) *IntSliceCmd
}
Hook
This type doesn't have documentation.
type Hook interface {
DialHook(next DialHook) DialHook
ProcessHook(next ProcessHook) ProcessHook
ProcessPipelineHook(next ProcessPipelineHook) ProcessPipelineHook
}
HyperLogLogCmdable
This type doesn't have documentation.
type HyperLogLogCmdable interface {
PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd
PFCount(ctx context.Context, keys ...string) *IntCmd
PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd
}
IndexDefinition
This type doesn't have documentation.
type IndexDefinition struct {
KeyType string
Prefixes []string
DefaultScore float64
}
IndexErrors
This type doesn't have documentation.
type IndexErrors struct {
IndexingFailures int
LastIndexingError string
LastIndexingErrorKey string
}
InfoCmd
This type doesn't have documentation.
type InfoCmd struct {
baseCmd
val map[string]map[string]string
}
IntCmd
This type doesn't have documentation.
type IntCmd struct {
baseCmd
val int64
}
IntPointerSliceCmd
This type doesn't have documentation.
type IntPointerSliceCmd struct {
baseCmd
val []*int64
}
IntSliceCmd
This type doesn't have documentation.
type IntSliceCmd struct {
baseCmd
val []int64
}
JSONArrIndexArgs
This type doesn't have documentation.
type JSONArrIndexArgs struct {
Start int
Stop *int
}
JSONArrTrimArgs
This type doesn't have documentation.
type JSONArrTrimArgs struct {
Start int
Stop *int
}
JSONCmd
This type doesn't have documentation.
type JSONCmd struct {
baseCmd
val string
expanded interface{}
}
JSONCmdable
This type doesn't have documentation.
type JSONCmdable interface {
JSONArrAppend(ctx context.Context, key, path string, values ...interface{}) *IntSliceCmd
JSONArrIndex(ctx context.Context, key, path string, value ...interface{}) *IntSliceCmd
JSONArrIndexWithArgs(ctx context.Context, key, path string, options *JSONArrIndexArgs, value ...interface{}) *IntSliceCmd
JSONArrInsert(ctx context.Context, key, path string, index int64, values ...interface{}) *IntSliceCmd
JSONArrLen(ctx context.Context, key, path string) *IntSliceCmd
JSONArrPop(ctx context.Context, key, path string, index int) *StringSliceCmd
JSONArrTrim(ctx context.Context, key, path string) *IntSliceCmd
JSONArrTrimWithArgs(ctx context.Context, key, path string, options *JSONArrTrimArgs) *IntSliceCmd
JSONClear(ctx context.Context, key, path string) *IntCmd
JSONDebugMemory(ctx context.Context, key, path string) *IntCmd
JSONDel(ctx context.Context, key, path string) *IntCmd
JSONForget(ctx context.Context, key, path string) *IntCmd
JSONGet(ctx context.Context, key string, paths ...string) *JSONCmd
JSONGetWithArgs(ctx context.Context, key string, options *JSONGetArgs, paths ...string) *JSONCmd
JSONMerge(ctx context.Context, key, path string, value string) *StatusCmd
JSONMSetArgs(ctx context.Context, docs []JSONSetArgs) *StatusCmd
JSONMSet(ctx context.Context, params ...interface{}) *StatusCmd
JSONMGet(ctx context.Context, path string, keys ...string) *JSONSliceCmd
JSONNumIncrBy(ctx context.Context, key, path string, value float64) *JSONCmd
JSONObjKeys(ctx context.Context, key, path string) *SliceCmd
JSONObjLen(ctx context.Context, key, path string) *IntPointerSliceCmd
JSONSet(ctx context.Context, key, path string, value interface{}) *StatusCmd
JSONSetMode(ctx context.Context, key, path string, value interface{}, mode string) *StatusCmd
JSONStrAppend(ctx context.Context, key, path, value string) *IntPointerSliceCmd
JSONStrLen(ctx context.Context, key, path string) *IntPointerSliceCmd
JSONToggle(ctx context.Context, key, path string) *IntPointerSliceCmd
JSONType(ctx context.Context, key, path string) *JSONSliceCmd
}
JSONGetArgs
This type doesn't have documentation.
type JSONGetArgs struct {
Indent string
Newline string
Space string
}
JSONSetArgs
This type doesn't have documentation.
type JSONSetArgs struct {
Key string
Path string
Value interface{}
}
JSONSliceCmd
This type doesn't have documentation.
type JSONSliceCmd struct {
baseCmd
val []interface{}
}
KeyFlags
This type doesn't have documentation.
type KeyFlags struct {
Key string
Flags []string
}
KeyFlagsCmd
This type doesn't have documentation.
type KeyFlagsCmd struct {
baseCmd
val []KeyFlags
}
KeyValue
This type doesn't have documentation.
type KeyValue struct {
Key string
Value string
}
KeyValueSliceCmd
This type doesn't have documentation.
type KeyValueSliceCmd struct {
baseCmd
val []KeyValue
}
KeyValuesCmd
This type doesn't have documentation.
type KeyValuesCmd struct {
baseCmd
key string
val []string
}
LCSCmd
This type doesn't have documentation.
type LCSCmd struct {
baseCmd
// 1: match string
// 2: match len
// 3: match idx LCSMatch
readType uint8
val *LCSMatch
}
LCSMatch
LCSMatch is the result set of the LCS command.
type LCSMatch struct {
MatchString string
Matches []LCSMatchedPosition
Len int64
}
LCSMatchedPosition
This type doesn't have documentation.
type LCSMatchedPosition struct {
Key1 LCSPosition
Key2 LCSPosition
// only for withMatchLen is true
MatchLen int64
}
LCSPosition
This type doesn't have documentation.
type LCSPosition struct {
Start int64
End int64
}
LCSQuery
LCSQuery is a parameter used for the LCS command
type LCSQuery struct {
Key1 string
Key2 string
Len bool
Idx bool
MinMatchLen int
WithMatchLen bool
}
LPosArgs
This type doesn't have documentation.
type LPosArgs struct {
Rank, MaxLen int64
}
Library
This type doesn't have documentation.
type Library struct {
Name string
Engine string
Functions []Function
Code string
}
LibraryInfo
LibraryInfo holds the library info.
type LibraryInfo struct {
LibName *string
LibVer *string
}
Limiter
Limiter is the interface of a rate limiter or a circuit breaker.
type Limiter interface {
// Allow returns nil if operation is allowed or an error otherwise.
// If operation is allowed client must ReportResult of the operation
// whether it is a success or a failure.
Allow() error
// ReportResult reports the result of the previously allowed operation.
// nil indicates a success, non-nil error usually indicates a failure.
ReportResult(result error)
}
ListCmdable
This type doesn't have documentation.
type ListCmdable interface {
BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
BLMPop(ctx context.Context, timeout time.Duration, direction string, count int64, keys ...string) *KeyValuesCmd
BRPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd
BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *StringCmd
LIndex(ctx context.Context, key string, index int64) *StringCmd
LInsert(ctx context.Context, key, op string, pivot, value interface{}) *IntCmd
LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *IntCmd
LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd
LLen(ctx context.Context, key string) *IntCmd
LMPop(ctx context.Context, direction string, count int64, keys ...string) *KeyValuesCmd
LPop(ctx context.Context, key string) *StringCmd
LPopCount(ctx context.Context, key string, count int) *StringSliceCmd
LPos(ctx context.Context, key string, value string, args LPosArgs) *IntCmd
LPosCount(ctx context.Context, key string, value string, count int64, args LPosArgs) *IntSliceCmd
LPush(ctx context.Context, key string, values ...interface{}) *IntCmd
LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
LRem(ctx context.Context, key string, count int64, value interface{}) *IntCmd
LSet(ctx context.Context, key string, index int64, value interface{}) *StatusCmd
LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd
RPop(ctx context.Context, key string) *StringCmd
RPopCount(ctx context.Context, key string, count int) *StringSliceCmd
RPopLPush(ctx context.Context, source, destination string) *StringCmd
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd
BLMove(ctx context.Context, source, destination, srcpos, destpos string, timeout time.Duration) *StringCmd
}
MapMapStringInterfaceCmd
MapStringInterfaceCmd represents a command that returns a map of strings to interface{}.
type MapMapStringInterfaceCmd struct {
baseCmd
val map[string]interface{}
}
MapStringIntCmd
This type doesn't have documentation.
type MapStringIntCmd struct {
baseCmd
val map[string]int64
}
MapStringInterfaceCmd
This type doesn't have documentation.
type MapStringInterfaceCmd struct {
baseCmd
val map[string]interface{}
}
MapStringInterfaceSliceCmd
This type doesn't have documentation.
type MapStringInterfaceSliceCmd struct {
baseCmd
val []map[string]interface{}
}
MapStringSliceInterfaceCmd
type MapStringSliceInterfaceCmd struct {
baseCmd
val map[string][]interface{}
}
MapStringStringCmd
This type doesn't have documentation.
type MapStringStringCmd struct {
baseCmd
val map[string]string
}
MapStringStringSliceCmd
This type doesn't have documentation.
type MapStringStringSliceCmd struct {
baseCmd
val []map[string]string
}
Message
Message received as result of a PUBLISH command issued by another client.
type Message struct {
Channel string
Pattern string
Payload string
PayloadSlice []string
}
ModuleLoadexConfig
ModuleLoadexConfig struct is used to specify the arguments for the MODULE LOADEX command of redis.
MODULE LOADEX path [CONFIG name value [CONFIG name value ...]] [ARGS args [args ...]]
type ModuleLoadexConfig struct {
Path string
Conf map[string]interface{}
Args []interface{}
}
MonitorCmd
This type doesn't have documentation.
type MonitorCmd struct {
baseCmd
ch chan string
status MonitorStatus
mu sync.Mutex
}
MonitorStatus
This type doesn't have documentation.
type MonitorStatus int
Node
This type doesn't have documentation.
type Node struct {
ID string
Endpoint string
IP string
Hostname string
Port int64
TLSPort int64
Role string
ReplicationOffset int64
Health string
}
Options
Options keeps the settings to set up redis connection.
type Options struct {
// The network type, either tcp or unix.
// Default is tcp.
Network string
// host:port address.
Addr string
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
ClientName string
// Dialer creates new network connection and has priority over
// Network and Addr options.
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
// Hook that is called when new connection is established.
OnConnect func(ctx context.Context, cn *Conn) error
// Protocol 2 or 3. Use the version to negotiate RESP version with redis-server.
// Default is 3.
Protocol int
// Use the specified Username to authenticate the current connection
// with one of the connections defined in the ACL list when connecting
// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
Username string
// Optional password. Must match the password specified in the
// requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
// or the User Password when connecting to a Redis 6.0 instance, or greater,
// that is using the Redis ACL system.
Password string
// CredentialsProvider allows the username and password to be updated
// before reconnecting. It should return the current username and password.
CredentialsProvider func() (username string, password string)
// CredentialsProviderContext is an enhanced parameter of CredentialsProvider,
// done to maintain API compatibility. In the future,
// there might be a merge between CredentialsProviderContext and CredentialsProvider.
// There will be a conflict between them; if CredentialsProviderContext exists, we will ignore CredentialsProvider.
CredentialsProviderContext func(ctx context.Context) (username string, password string, err error)
// Database to be selected after connecting to the server.
DB int
// Maximum number of retries before giving up.
// Default is 3 retries; -1 (not 0) disables retries.
MaxRetries int
// Minimum backoff between each retry.
// Default is 8 milliseconds; -1 disables backoff.
MinRetryBackoff time.Duration
// Maximum backoff between each retry.
// Default is 512 milliseconds; -1 disables backoff.
MaxRetryBackoff time.Duration
// Dial timeout for establishing new connections.
// Default is 5 seconds.
DialTimeout time.Duration
// Timeout for socket reads. If reached, commands will fail
// with a timeout instead of blocking. Supported values:
// - `0` - default timeout (3 seconds).
// - `-1` - no timeout (block indefinitely).
// - `-2` - disables SetReadDeadline calls completely.
ReadTimeout time.Duration
// Timeout for socket writes. If reached, commands will fail
// with a timeout instead of blocking. Supported values:
// - `0` - default timeout (3 seconds).
// - `-1` - no timeout (block indefinitely).
// - `-2` - disables SetWriteDeadline calls completely.
WriteTimeout time.Duration
// ContextTimeoutEnabled controls whether the client respects context timeouts and deadlines.
// See https://redis.uptrace.dev/guide/go-redis-debugging.html#timeouts
ContextTimeoutEnabled bool
// Type of connection pool.
// true for FIFO pool, false for LIFO pool.
// Note that FIFO has slightly higher overhead compared to LIFO,
// but it helps closing idle connections faster reducing the pool size.
PoolFIFO bool
// Base number of socket connections.
// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
// If there is not enough connections in the pool, new connections will be allocated in excess of PoolSize,
// you can limit it through MaxActiveConns
PoolSize int
// Amount of time client waits for connection if all connections
// are busy before returning an error.
// Default is ReadTimeout + 1 second.
PoolTimeout time.Duration
// Minimum number of idle connections which is useful when establishing
// new connection is slow.
// Default is 0. the idle connections are not closed by default.
MinIdleConns int
// Maximum number of idle connections.
// Default is 0. the idle connections are not closed by default.
MaxIdleConns int
// Maximum number of connections allocated by the pool at a given time.
// When zero, there is no limit on the number of connections in the pool.
MaxActiveConns int
// ConnMaxIdleTime is the maximum amount of time a connection may be idle.
// Should be less than server's timeout.
//
// Expired connections may be closed lazily before reuse.
// If d <= 0, connections are not closed due to a connection's idle time.
//
// Default is 30 minutes. -1 disables idle timeout check.
ConnMaxIdleTime time.Duration
// ConnMaxLifetime is the maximum amount of time a connection may be reused.
//
// Expired connections may be closed lazily before reuse.
// If <= 0, connections are not closed due to a connection's age.
//
// Default is to not close idle connections.
ConnMaxLifetime time.Duration
// TLS Config to use. When set, TLS will be negotiated.
TLSConfig *tls.Config
// Limiter interface used to implement circuit breaker or rate limiter.
Limiter Limiter
// Enables read only queries on slave/follower nodes.
readOnly bool
// Disable set-lib on connect. Default is false.
DisableIndentity bool
// Add suffix to client name. Default is empty.
IdentitySuffix string
// Enable Unstable mode for Redis Search module with RESP3.
UnstableResp3 bool
}
Pipeline
Pipeline implements pipelining as described in http://redis.io/topics/pipelining. Please note: it is not safe for concurrent use by multiple goroutines.
type Pipeline struct {
cmdable
statefulCmdable
exec pipelineExecer
cmds []Cmder
}
Pipeliner
Pipeliner is an mechanism to realise Redis Pipeline technique.
Pipelining is a technique to extremely speed up processing by packing operations to batches, send them at once to Redis and read a replies in a single step. See https://redis.io/topics/pipelining
Pay attention, that Pipeline is not a transaction, so you can get unexpected results in case of big pipelines and small read/write timeouts. Redis client has retransmission logic in case of timeouts, pipeline can be retransmitted and commands can be executed more then once. To avoid this: it is good idea to use reasonable bigger read/write timeouts depends of your batch size and/or use TxPipeline.
type Pipeliner interface {
StatefulCmdable
// Len is to obtain the number of commands in the pipeline that have not yet been executed.
Len() int
// Do is an API for executing any command.
// If a certain Redis command is not yet supported, you can use Do to execute it.
Do(ctx context.Context, args ...interface{}) *Cmd
// Process is to put the commands to be executed into the pipeline buffer.
Process(ctx context.Context, cmd Cmder) error
// Discard is to discard all commands in the cache that have not yet been executed.
Discard()
// Exec is to send all the commands buffered in the pipeline to the redis-server.
Exec(ctx context.Context) ([]Cmder, error)
}
Pong
Pong received as result of a PING command issued by another client.
type Pong struct {
Payload string
}
PoolStats
This type doesn't have documentation.
type PoolStats pool.Stats
ProbabilisticCmdable
This type doesn't have documentation.
type ProbabilisticCmdable interface {
BFAdd(ctx context.Context, key string, element interface{}) *BoolCmd
BFCard(ctx context.Context, key string) *IntCmd
BFExists(ctx context.Context, key string, element interface{}) *BoolCmd
BFInfo(ctx context.Context, key string) *BFInfoCmd
BFInfoArg(ctx context.Context, key, option string) *BFInfoCmd
BFInfoCapacity(ctx context.Context, key string) *BFInfoCmd
BFInfoSize(ctx context.Context, key string) *BFInfoCmd
BFInfoFilters(ctx context.Context, key string) *BFInfoCmd
BFInfoItems(ctx context.Context, key string) *BFInfoCmd
BFInfoExpansion(ctx context.Context, key string) *BFInfoCmd
BFInsert(ctx context.Context, key string, options *BFInsertOptions, elements ...interface{}) *BoolSliceCmd
BFMAdd(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
BFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
BFReserve(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd
BFReserveExpansion(ctx context.Context, key string, errorRate float64, capacity, expansion int64) *StatusCmd
BFReserveNonScaling(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd
BFReserveWithArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd
BFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd
BFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd
CFAdd(ctx context.Context, key string, element interface{}) *BoolCmd
CFAddNX(ctx context.Context, key string, element interface{}) *BoolCmd
CFCount(ctx context.Context, key string, element interface{}) *IntCmd
CFDel(ctx context.Context, key string, element interface{}) *BoolCmd
CFExists(ctx context.Context, key string, element interface{}) *BoolCmd
CFInfo(ctx context.Context, key string) *CFInfoCmd
CFInsert(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *BoolSliceCmd
CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd
CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
CFReserve(ctx context.Context, key string, capacity int64) *StatusCmd
CFReserveWithArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd
CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd
CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd
CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd
CFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd
CFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd
CMSIncrBy(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd
CMSInfo(ctx context.Context, key string) *CMSInfoCmd
CMSInitByDim(ctx context.Context, key string, width, height int64) *StatusCmd
CMSInitByProb(ctx context.Context, key string, errorRate, probability float64) *StatusCmd
CMSMerge(ctx context.Context, destKey string, sourceKeys ...string) *StatusCmd
CMSMergeWithWeight(ctx context.Context, destKey string, sourceKeys map[string]int64) *StatusCmd
CMSQuery(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd
TopKAdd(ctx context.Context, key string, elements ...interface{}) *StringSliceCmd
TopKCount(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd
TopKIncrBy(ctx context.Context, key string, elements ...interface{}) *StringSliceCmd
TopKInfo(ctx context.Context, key string) *TopKInfoCmd
TopKList(ctx context.Context, key string) *StringSliceCmd
TopKListWithCount(ctx context.Context, key string) *MapStringIntCmd
TopKQuery(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
TopKReserve(ctx context.Context, key string, k int64) *StatusCmd
TopKReserveWithOptions(ctx context.Context, key string, k int64, width, depth int64, decay float64) *StatusCmd
TDigestAdd(ctx context.Context, key string, elements ...float64) *StatusCmd
TDigestByRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd
TDigestByRevRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd
TDigestCDF(ctx context.Context, key string, elements ...float64) *FloatSliceCmd
TDigestCreate(ctx context.Context, key string) *StatusCmd
TDigestCreateWithCompression(ctx context.Context, key string, compression int64) *StatusCmd
TDigestInfo(ctx context.Context, key string) *TDigestInfoCmd
TDigestMax(ctx context.Context, key string) *FloatCmd
TDigestMin(ctx context.Context, key string) *FloatCmd
TDigestMerge(ctx context.Context, destKey string, options *TDigestMergeOptions, sourceKeys ...string) *StatusCmd
TDigestQuantile(ctx context.Context, key string, elements ...float64) *FloatSliceCmd
TDigestRank(ctx context.Context, key string, values ...float64) *IntSliceCmd
TDigestReset(ctx context.Context, key string) *StatusCmd
TDigestRevRank(ctx context.Context, key string, values ...float64) *IntSliceCmd
TDigestTrimmedMean(ctx context.Context, key string, lowCutQuantile, highCutQuantile float64) *FloatCmd
}
PubSub
PubSub implements Pub/Sub commands as described in http://redis.io/topics/pubsub. Message receiving is NOT safe for concurrent use by multiple goroutines.
PubSub automatically reconnects to Redis Server and resubscribes to the channels in case of network errors.
type PubSub struct {
opt *Options
newConn func(ctx context.Context, channels []string) (*pool.Conn, error)
closeConn func(*pool.Conn) error
mu sync.Mutex
cn *pool.Conn
channels map[string]struct{}
patterns map[string]struct{}
schannels map[string]struct{}
closed bool
exit chan struct{}
cmd *Cmd
chOnce sync.Once
msgCh *channel
allCh *channel
}
PubSubCmdable
This type doesn't have documentation.
type PubSubCmdable interface {
Publish(ctx context.Context, channel string, message interface{}) *IntCmd
SPublish(ctx context.Context, channel string, message interface{}) *IntCmd
PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd
PubSubNumSub(ctx context.Context, channels ...string) *MapStringIntCmd
PubSubNumPat(ctx context.Context) *IntCmd
PubSubShardChannels(ctx context.Context, pattern string) *StringSliceCmd
PubSubShardNumSub(ctx context.Context, channels ...string) *MapStringIntCmd
}
RankScore
This type doesn't have documentation.
type RankScore struct {
Rank int64
Score float64
}
RankWithScoreCmd
This type doesn't have documentation.
type RankWithScoreCmd struct {
baseCmd
val RankScore
}
Ring
Ring is a Redis client that uses consistent hashing to distribute keys across multiple Redis servers (shards). It's safe for concurrent use by multiple goroutines.
Ring monitors the state of each shard and removes dead shards from the ring. When a shard comes online it is added back to the ring. This gives you maximum availability and partition tolerance, but no consistency between different shards or even clients. Each client uses shards that are available to the client and does not do any coordination when shard state is changed.
Ring should be used when you need multiple Redis servers for caching and can tolerate losing data when one of the servers dies. Otherwise you should use Redis Cluster.
type Ring struct {
cmdable
hooksMixin
opt *RingOptions
sharding *ringSharding
cmdsInfoCache *cmdsInfoCache
heartbeatCancelFn context.CancelFunc
}
RingOptions
RingOptions are used to configure a ring client and should be passed to NewRing.
type RingOptions struct {
// Map of name => host:port addresses of ring shards.
Addrs map[string]string
// NewClient creates a shard client with provided options.
NewClient func(opt *Options) *Client
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
ClientName string
// Frequency of PING commands sent to check shards availability.
// Shard is considered down after 3 subsequent failed checks.
HeartbeatFrequency time.Duration
// NewConsistentHash returns a consistent hash that is used
// to distribute keys across the shards.
//
// See https://medium.com/@dgryski/consistent-hashing-algorithmic-tradeoffs-ef6b8e2fcae8
// for consistent hashing algorithmic tradeoffs.
NewConsistentHash func(shards []string) ConsistentHash
// Following options are copied from Options struct.
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error
Protocol int
Username string
Password string
DB int
MaxRetries int
MinRetryBackoff time.Duration
MaxRetryBackoff time.Duration
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
ContextTimeoutEnabled bool
// PoolFIFO uses FIFO mode for each node connection pool GET/PUT (default LIFO).
PoolFIFO bool
PoolSize int
PoolTimeout time.Duration
MinIdleConns int
MaxIdleConns int
MaxActiveConns int
ConnMaxIdleTime time.Duration
ConnMaxLifetime time.Duration
TLSConfig *tls.Config
Limiter Limiter
DisableIndentity bool
IdentitySuffix string
UnstableResp3 bool
}
RunningScript
This type doesn't have documentation.
type RunningScript struct {
Name string
Command []string
Duration time.Duration
}
ScanCmd
This type doesn't have documentation.
type ScanCmd struct {
baseCmd
page []string
cursor uint64
process cmdable
}
ScanDump
This type doesn't have documentation.
type ScanDump struct {
Iter int64
Data string
}
ScanDumpCmd
This type doesn't have documentation.
type ScanDumpCmd struct {
baseCmd
val ScanDump
}
ScanIterator
ScanIterator is used to incrementally iterate over a collection of elements.
type ScanIterator struct {
cmd *ScanCmd
pos int
}
Scanner
Scanner internal/hscan.Scanner exposed interface.
type Scanner = hscan.Scanner
Script
This type doesn't have documentation.
type Script struct {
src, hash string
}
Scripter
This type doesn't have documentation.
type Scripter interface {
Eval(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd
EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd
EvalRO(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd
EvalShaRO(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd
ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd
ScriptLoad(ctx context.Context, script string) *StringCmd
}
ScriptingFunctionsCmdable
This type doesn't have documentation.
type ScriptingFunctionsCmdable interface {
Eval(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd
EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd
EvalRO(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd
EvalShaRO(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd
ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd
ScriptFlush(ctx context.Context) *StatusCmd
ScriptKill(ctx context.Context) *StatusCmd
ScriptLoad(ctx context.Context, script string) *StringCmd
FunctionLoad(ctx context.Context, code string) *StringCmd
FunctionLoadReplace(ctx context.Context, code string) *StringCmd
FunctionDelete(ctx context.Context, libName string) *StringCmd
FunctionFlush(ctx context.Context) *StringCmd
FunctionKill(ctx context.Context) *StringCmd
FunctionFlushAsync(ctx context.Context) *StringCmd
FunctionList(ctx context.Context, q FunctionListQuery) *FunctionListCmd
FunctionDump(ctx context.Context) *StringCmd
FunctionRestore(ctx context.Context, libDump string) *StringCmd
FunctionStats(ctx context.Context) *FunctionStatsCmd
FCall(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd
FCallRo(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd
FCallRO(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd
}
SearchAggregator
This type doesn't have documentation.
type SearchAggregator int
SearchCmdable
This type doesn't have documentation.
type SearchCmdable interface {
FT_List(ctx context.Context) *StringSliceCmd
FTAggregate(ctx context.Context, index string, query string) *MapStringInterfaceCmd
FTAggregateWithArgs(ctx context.Context, index string, query string, options *FTAggregateOptions) *AggregateCmd
FTAliasAdd(ctx context.Context, index string, alias string) *StatusCmd
FTAliasDel(ctx context.Context, alias string) *StatusCmd
FTAliasUpdate(ctx context.Context, index string, alias string) *StatusCmd
FTAlter(ctx context.Context, index string, skipInitialScan bool, definition []interface{}) *StatusCmd
FTConfigGet(ctx context.Context, option string) *MapMapStringInterfaceCmd
FTConfigSet(ctx context.Context, option string, value interface{}) *StatusCmd
FTCreate(ctx context.Context, index string, options *FTCreateOptions, schema ...*FieldSchema) *StatusCmd
FTCursorDel(ctx context.Context, index string, cursorId int) *StatusCmd
FTCursorRead(ctx context.Context, index string, cursorId int, count int) *MapStringInterfaceCmd
FTDictAdd(ctx context.Context, dict string, term ...interface{}) *IntCmd
FTDictDel(ctx context.Context, dict string, term ...interface{}) *IntCmd
FTDictDump(ctx context.Context, dict string) *StringSliceCmd
FTDropIndex(ctx context.Context, index string) *StatusCmd
FTDropIndexWithArgs(ctx context.Context, index string, options *FTDropIndexOptions) *StatusCmd
FTExplain(ctx context.Context, index string, query string) *StringCmd
FTExplainWithArgs(ctx context.Context, index string, query string, options *FTExplainOptions) *StringCmd
FTInfo(ctx context.Context, index string) *FTInfoCmd
FTSpellCheck(ctx context.Context, index string, query string) *FTSpellCheckCmd
FTSpellCheckWithArgs(ctx context.Context, index string, query string, options *FTSpellCheckOptions) *FTSpellCheckCmd
FTSearch(ctx context.Context, index string, query string) *FTSearchCmd
FTSearchWithArgs(ctx context.Context, index string, query string, options *FTSearchOptions) *FTSearchCmd
FTSynDump(ctx context.Context, index string) *FTSynDumpCmd
FTSynUpdate(ctx context.Context, index string, synGroupId interface{}, terms []interface{}) *StatusCmd
FTSynUpdateWithArgs(ctx context.Context, index string, synGroupId interface{}, options *FTSynUpdateOptions, terms []interface{}) *StatusCmd
FTTagVals(ctx context.Context, index string, field string) *StringSliceCmd
}
SearchFieldType
This type doesn't have documentation.
type SearchFieldType int
SearchQuery
This type doesn't have documentation.
type SearchQuery []interface{}
SentinelClient
SentinelClient is a client for a Redis Sentinel.
type SentinelClient struct {
*baseClient
hooksMixin
}
SetArgs
SetArgs provides arguments for the SetArgs function.
type SetArgs struct {
// Mode can be `NX` or `XX` or empty.
Mode string
// Zero `TTL` or `Expiration` means that the key has no expiration time.
TTL time.Duration
ExpireAt time.Time
// When Get is true, the command returns the old value stored at key, or nil when key did not exist.
Get bool
// KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0,
// otherwise you will receive an error: (error) ERR syntax error.
KeepTTL bool
}
SetCmdable
This type doesn't have documentation.
type SetCmdable interface {
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
SCard(ctx context.Context, key string) *IntCmd
SDiff(ctx context.Context, keys ...string) *StringSliceCmd
SDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd
SInter(ctx context.Context, keys ...string) *StringSliceCmd
SInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd
SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd
SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd
SMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmd
SMembers(ctx context.Context, key string) *StringSliceCmd
SMembersMap(ctx context.Context, key string) *StringStructMapCmd
SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd
SPop(ctx context.Context, key string) *StringCmd
SPopN(ctx context.Context, key string, count int64) *StringSliceCmd
SRandMember(ctx context.Context, key string) *StringCmd
SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd
SRem(ctx context.Context, key string, members ...interface{}) *IntCmd
SScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
SUnion(ctx context.Context, keys ...string) *StringSliceCmd
SUnionStore(ctx context.Context, destination string, keys ...string) *IntCmd
}
SliceCmd
This type doesn't have documentation.
type SliceCmd struct {
baseCmd
val []interface{}
}
SlotRange
This type doesn't have documentation.
type SlotRange struct {
Start int64
End int64
}
SlowLog
This type doesn't have documentation.
type SlowLog struct {
ID int64
Time time.Time
Duration time.Duration
Args []string
// These are also optional fields emitted only by Redis 4.0 or greater:
// https://redis.io/commands/slowlog#output-format
ClientAddr string
ClientName string
}
SlowLogCmd
This type doesn't have documentation.
type SlowLogCmd struct {
baseCmd
val []SlowLog
}
Sort
This type doesn't have documentation.
type Sort struct {
By string
Offset, Count int64
Get []string
Order string
Alpha bool
}
SortedSetCmdable
This type doesn't have documentation.
type SortedSetCmdable interface {
BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd
BZMPop(ctx context.Context, timeout time.Duration, order string, count int64, keys ...string) *ZSliceWithKeyCmd
ZAdd(ctx context.Context, key string, members ...Z) *IntCmd
ZAddLT(ctx context.Context, key string, members ...Z) *IntCmd
ZAddGT(ctx context.Context, key string, members ...Z) *IntCmd
ZAddNX(ctx context.Context, key string, members ...Z) *IntCmd
ZAddXX(ctx context.Context, key string, members ...Z) *IntCmd
ZAddArgs(ctx context.Context, key string, args ZAddArgs) *IntCmd
ZAddArgsIncr(ctx context.Context, key string, args ZAddArgs) *FloatCmd
ZCard(ctx context.Context, key string) *IntCmd
ZCount(ctx context.Context, key, min, max string) *IntCmd
ZLexCount(ctx context.Context, key, min, max string) *IntCmd
ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd
ZInter(ctx context.Context, store *ZStore) *StringSliceCmd
ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd
ZInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd
ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd
ZMPop(ctx context.Context, order string, count int64, keys ...string) *ZSliceWithKeyCmd
ZMScore(ctx context.Context, key string, members ...string) *FloatSliceCmd
ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd
ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd
ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd
ZRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
ZRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
ZRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd
ZRangeArgs(ctx context.Context, z ZRangeArgs) *StringSliceCmd
ZRangeArgsWithScores(ctx context.Context, z ZRangeArgs) *ZSliceCmd
ZRangeStore(ctx context.Context, dst string, z ZRangeArgs) *IntCmd
ZRank(ctx context.Context, key, member string) *IntCmd
ZRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd
ZRem(ctx context.Context, key string, members ...interface{}) *IntCmd
ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd
ZRemRangeByScore(ctx context.Context, key, min, max string) *IntCmd
ZRemRangeByLex(ctx context.Context, key, min, max string) *IntCmd
ZRevRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd
ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd
ZRevRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
ZRevRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd
ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd
ZRevRank(ctx context.Context, key, member string) *IntCmd
ZRevRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd
ZScore(ctx context.Context, key, member string) *FloatCmd
ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd
ZRandMember(ctx context.Context, key string, count int) *StringSliceCmd
ZRandMemberWithScores(ctx context.Context, key string, count int) *ZSliceCmd
ZUnion(ctx context.Context, store ZStore) *StringSliceCmd
ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd
ZDiff(ctx context.Context, keys ...string) *StringSliceCmd
ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd
ZDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd
ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
}
SpellCheckResult
This type doesn't have documentation.
type SpellCheckResult struct {
Term string
Suggestions []SpellCheckSuggestion
}
SpellCheckSuggestion
This type doesn't have documentation.
type SpellCheckSuggestion struct {
Score float64
Suggestion string
}
SpellCheckTerms
This type doesn't have documentation.
type SpellCheckTerms struct {
Include bool
Exclude bool
Dictionary string
}
StatefulCmdable
This type doesn't have documentation.
type StatefulCmdable interface {
Cmdable
Auth(ctx context.Context, password string) *StatusCmd
AuthACL(ctx context.Context, username, password string) *StatusCmd
Select(ctx context.Context, index int) *StatusCmd
SwapDB(ctx context.Context, index1, index2 int) *StatusCmd
ClientSetName(ctx context.Context, name string) *BoolCmd
ClientSetInfo(ctx context.Context, info LibraryInfo) *StatusCmd
Hello(ctx context.Context, ver int, username, password, clientName string) *MapStringInterfaceCmd
}
StatusCmd
This type doesn't have documentation.
type StatusCmd struct {
baseCmd
val string
}
StreamCmdable
This type doesn't have documentation.
type StreamCmdable interface {
XAdd(ctx context.Context, a *XAddArgs) *StringCmd
XDel(ctx context.Context, stream string, ids ...string) *IntCmd
XLen(ctx context.Context, stream string) *IntCmd
XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd
XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd
XRevRange(ctx context.Context, stream string, start, stop string) *XMessageSliceCmd
XRevRangeN(ctx context.Context, stream string, start, stop string, count int64) *XMessageSliceCmd
XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd
XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd
XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd
XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd
XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd
XGroupDestroy(ctx context.Context, stream, group string) *IntCmd
XGroupCreateConsumer(ctx context.Context, stream, group, consumer string) *IntCmd
XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd
XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd
XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd
XPending(ctx context.Context, stream, group string) *XPendingCmd
XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd
XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd
XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd
XAutoClaim(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimCmd
XAutoClaimJustID(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimJustIDCmd
XTrimMaxLen(ctx context.Context, key string, maxLen int64) *IntCmd
XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) *IntCmd
XTrimMinID(ctx context.Context, key string, minID string) *IntCmd
XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd
XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd
XInfoStream(ctx context.Context, key string) *XInfoStreamCmd
XInfoStreamFull(ctx context.Context, key string, count int) *XInfoStreamFullCmd
XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd
}
StringCmd
This type doesn't have documentation.
type StringCmd struct {
baseCmd
val string
}
StringCmdable
This type doesn't have documentation.
type StringCmdable interface {
Append(ctx context.Context, key, value string) *IntCmd
Decr(ctx context.Context, key string) *IntCmd
DecrBy(ctx context.Context, key string, decrement int64) *IntCmd
Get(ctx context.Context, key string) *StringCmd
GetRange(ctx context.Context, key string, start, end int64) *StringCmd
GetSet(ctx context.Context, key string, value interface{}) *StringCmd
GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd
GetDel(ctx context.Context, key string) *StringCmd
Incr(ctx context.Context, key string) *IntCmd
IncrBy(ctx context.Context, key string, value int64) *IntCmd
IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd
LCS(ctx context.Context, q *LCSQuery) *LCSCmd
MGet(ctx context.Context, keys ...string) *SliceCmd
MSet(ctx context.Context, values ...interface{}) *StatusCmd
MSetNX(ctx context.Context, values ...interface{}) *BoolCmd
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd
SetEx(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd
StrLen(ctx context.Context, key string) *IntCmd
}
StringSliceCmd
This type doesn't have documentation.
type StringSliceCmd struct {
baseCmd
val []string
}
StringStructMapCmd
This type doesn't have documentation.
type StringStructMapCmd struct {
baseCmd
val map[string]struct{}
}
Subscription
Subscription received after a successful subscription to channel.
type Subscription struct {
// Can be "subscribe", "unsubscribe", "psubscribe" or "punsubscribe".
Kind string
// Channel name we have subscribed to.
Channel string
// Number of channels we are currently subscribed to.
Count int
}
TDigestInfo
This type doesn't have documentation.
type TDigestInfo struct {
Compression int64
Capacity int64
MergedNodes int64
UnmergedNodes int64
MergedWeight int64
UnmergedWeight int64
Observations int64
TotalCompressions int64
MemoryUsage int64
}
TDigestInfoCmd
This type doesn't have documentation.
type TDigestInfoCmd struct {
baseCmd
val TDigestInfo
}
TDigestMergeOptions
This type doesn't have documentation.
type TDigestMergeOptions struct {
Compression int64
Override bool
}
TFCallOptions
This type doesn't have documentation.
type TFCallOptions struct {
Keys []string
Arguments []string
}
TFunctionListOptions
This type doesn't have documentation.
type TFunctionListOptions struct {
Withcode bool
Verbose int
Library string
}
TFunctionLoadOptions
This type doesn't have documentation.
type TFunctionLoadOptions struct {
Replace bool
Config string
}
TSAlterOptions
This type doesn't have documentation.
type TSAlterOptions struct {
Retention int
ChunkSize int
DuplicatePolicy string
Labels map[string]string
IgnoreMaxTimeDiff int64
IgnoreMaxValDiff float64
}
TSCreateRuleOptions
This type doesn't have documentation.
type TSCreateRuleOptions struct {
alignTimestamp int64
}
TSGetOptions
This type doesn't have documentation.
type TSGetOptions struct {
Latest bool
}
TSIncrDecrOptions
This type doesn't have documentation.
type TSIncrDecrOptions struct {
Timestamp int64
Retention int
ChunkSize int
Uncompressed bool
DuplicatePolicy string
Labels map[string]string
IgnoreMaxTimeDiff int64
IgnoreMaxValDiff float64
}
TSInfoOptions
This type doesn't have documentation.
type TSInfoOptions struct {
Debug bool
}
TSMGetOptions
This type doesn't have documentation.
type TSMGetOptions struct {
Latest bool
WithLabels bool
SelectedLabels []interface{}
}
TSMRangeOptions
This type doesn't have documentation.
type TSMRangeOptions struct {
Latest bool
FilterByTS []int
FilterByValue []int
WithLabels bool
SelectedLabels []interface{}
Count int
Align interface{}
Aggregator Aggregator
BucketDuration int
BucketTimestamp interface{}
Empty bool
GroupByLabel interface{}
Reducer interface{}
}
TSMRevRangeOptions
This type doesn't have documentation.
type TSMRevRangeOptions struct {
Latest bool
FilterByTS []int
FilterByValue []int
WithLabels bool
SelectedLabels []interface{}
Count int
Align interface{}
Aggregator Aggregator
BucketDuration int
BucketTimestamp interface{}
Empty bool
GroupByLabel interface{}
Reducer interface{}
}
TSOptions
This type doesn't have documentation.
type TSOptions struct {
Retention int
ChunkSize int
Encoding string
DuplicatePolicy string
Labels map[string]string
IgnoreMaxTimeDiff int64
IgnoreMaxValDiff float64
}
TSRangeOptions
This type doesn't have documentation.
type TSRangeOptions struct {
Latest bool
FilterByTS []int
FilterByValue []int
Count int
Align interface{}
Aggregator Aggregator
BucketDuration int
BucketTimestamp interface{}
Empty bool
}
TSRevRangeOptions
This type doesn't have documentation.
type TSRevRangeOptions struct {
Latest bool
FilterByTS []int
FilterByValue []int
Count int
Align interface{}
Aggregator Aggregator
BucketDuration int
BucketTimestamp interface{}
Empty bool
}
TSTimestampValue
This type doesn't have documentation.
type TSTimestampValue struct {
Timestamp int64
Value float64
}
TSTimestampValueCmd
This type doesn't have documentation.
type TSTimestampValueCmd struct {
baseCmd
val TSTimestampValue
}
TSTimestampValueSliceCmd
This type doesn't have documentation.
type TSTimestampValueSliceCmd struct {
baseCmd
val []TSTimestampValue
}
TimeCmd
This type doesn't have documentation.
type TimeCmd struct {
baseCmd
val time.Time
}
TimeseriesCmdable
This type doesn't have documentation.
type TimeseriesCmdable interface {
TSAdd(ctx context.Context, key string, timestamp interface{}, value float64) *IntCmd
TSAddWithArgs(ctx context.Context, key string, timestamp interface{}, value float64, options *TSOptions) *IntCmd
TSCreate(ctx context.Context, key string) *StatusCmd
TSCreateWithArgs(ctx context.Context, key string, options *TSOptions) *StatusCmd
TSAlter(ctx context.Context, key string, options *TSAlterOptions) *StatusCmd
TSCreateRule(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int) *StatusCmd
TSCreateRuleWithArgs(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int, options *TSCreateRuleOptions) *StatusCmd
TSIncrBy(ctx context.Context, Key string, timestamp float64) *IntCmd
TSIncrByWithArgs(ctx context.Context, key string, timestamp float64, options *TSIncrDecrOptions) *IntCmd
TSDecrBy(ctx context.Context, Key string, timestamp float64) *IntCmd
TSDecrByWithArgs(ctx context.Context, key string, timestamp float64, options *TSIncrDecrOptions) *IntCmd
TSDel(ctx context.Context, Key string, fromTimestamp int, toTimestamp int) *IntCmd
TSDeleteRule(ctx context.Context, sourceKey string, destKey string) *StatusCmd
TSGet(ctx context.Context, key string) *TSTimestampValueCmd
TSGetWithArgs(ctx context.Context, key string, options *TSGetOptions) *TSTimestampValueCmd
TSInfo(ctx context.Context, key string) *MapStringInterfaceCmd
TSInfoWithArgs(ctx context.Context, key string, options *TSInfoOptions) *MapStringInterfaceCmd
TSMAdd(ctx context.Context, ktvSlices [][]interface{}) *IntSliceCmd
TSQueryIndex(ctx context.Context, filterExpr []string) *StringSliceCmd
TSRevRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd
TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRevRangeOptions) *TSTimestampValueSliceCmd
TSRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd
TSRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRangeOptions) *TSTimestampValueSliceCmd
TSMRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd
TSMRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRangeOptions) *MapStringSliceInterfaceCmd
TSMRevRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd
TSMRevRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRevRangeOptions) *MapStringSliceInterfaceCmd
TSMGet(ctx context.Context, filters []string) *MapStringSliceInterfaceCmd
TSMGetWithArgs(ctx context.Context, filters []string, options *TSMGetOptions) *MapStringSliceInterfaceCmd
}
TopKInfo
This type doesn't have documentation.
type TopKInfo struct {
K int64
Width int64
Depth int64
Decay float64
}
TopKInfoCmd
This type doesn't have documentation.
type TopKInfoCmd struct {
baseCmd
val TopKInfo
}
Tx
Tx implements Redis transactions as described in http://redis.io/topics/transactions. It's NOT safe for concurrent use by multiple goroutines, because Exec resets list of watched keys.
If you don't need WATCH, use Pipeline instead.
type Tx struct {
baseClient
cmdable
statefulCmdable
hooksMixin
}
UniversalClient
UniversalClient is an abstract client which - based on the provided options - represents either a ClusterClient, a FailoverClient, or a single-node Client. This can be useful for testing cluster-specific applications locally or having different clients in different environments.
type UniversalClient interface {
Cmdable
AddHook(Hook)
Watch(ctx context.Context, fn func(*Tx) error, keys ...string) error
Do(ctx context.Context, args ...interface{}) *Cmd
Process(ctx context.Context, cmd Cmder) error
Subscribe(ctx context.Context, channels ...string) *PubSub
PSubscribe(ctx context.Context, channels ...string) *PubSub
SSubscribe(ctx context.Context, channels ...string) *PubSub
Close() error
PoolStats() *PoolStats
}
UniversalOptions
UniversalOptions information is required by UniversalClient to establish connections.
type UniversalOptions struct {
// Either a single address or a seed list of host:port addresses
// of cluster/sentinel nodes.
Addrs []string
// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
ClientName string
// Database to be selected after connecting to the server.
// Only single-node and failover clients.
DB int
// Common options.
Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
OnConnect func(ctx context.Context, cn *Conn) error
Protocol int
Username string
Password string
SentinelUsername string
SentinelPassword string
MaxRetries int
MinRetryBackoff time.Duration
MaxRetryBackoff time.Duration
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
ContextTimeoutEnabled bool
// PoolFIFO uses FIFO mode for each node connection pool GET/PUT (default LIFO).
PoolFIFO bool
PoolSize int
PoolTimeout time.Duration
MinIdleConns int
MaxIdleConns int
MaxActiveConns int
ConnMaxIdleTime time.Duration
ConnMaxLifetime time.Duration
TLSConfig *tls.Config
// Only cluster clients.
MaxRedirects int
ReadOnly bool
RouteByLatency bool
RouteRandomly bool
// The sentinel master name.
// Only failover clients.
MasterName string
DisableIndentity bool
IdentitySuffix string
UnstableResp3 bool
}
XAddArgs
XAddArgs accepts values in the following formats:
- XAddArgs.Values = []interface{}{"key1", "value1", "key2", "value2"}
- XAddArgs.Values = []string("key1", "value1", "key2", "value2")
- XAddArgs.Values = map[string]interface{}{"key1": "value1", "key2": "value2"}
Note that map will not preserve the order of key-value pairs. MaxLen/MaxLenApprox and MinID are in conflict, only one of them can be used.
type XAddArgs struct {
Stream string
NoMkStream bool
MaxLen int64 // MAXLEN N
MinID string
// Approx causes MaxLen and MinID to use "~" matcher (instead of "=").
Approx bool
Limit int64
ID string
Values interface{}
}
XAutoClaimArgs
This type doesn't have documentation.
type XAutoClaimArgs struct {
Stream string
Group string
MinIdle time.Duration
Start string
Count int64
Consumer string
}
XAutoClaimCmd
This type doesn't have documentation.
type XAutoClaimCmd struct {
baseCmd
start string
val []XMessage
}
XAutoClaimJustIDCmd
This type doesn't have documentation.
type XAutoClaimJustIDCmd struct {
baseCmd
start string
val []string
}
XClaimArgs
This type doesn't have documentation.
type XClaimArgs struct {
Stream string
Group string
Consumer string
MinIdle time.Duration
Messages []string
}
XInfoConsumer
This type doesn't have documentation.
type XInfoConsumer struct {
Name string
Pending int64
Idle time.Duration
Inactive time.Duration
}
XInfoConsumersCmd
This type doesn't have documentation.
type XInfoConsumersCmd struct {
baseCmd
val []XInfoConsumer
}
XInfoGroup
This type doesn't have documentation.
type XInfoGroup struct {
Name string
Consumers int64
Pending int64
LastDeliveredID string
EntriesRead int64
Lag int64
}
XInfoGroupsCmd
This type doesn't have documentation.
type XInfoGroupsCmd struct {
baseCmd
val []XInfoGroup
}
XInfoStream
This type doesn't have documentation.
type XInfoStream struct {
Length int64
RadixTreeKeys int64
RadixTreeNodes int64
Groups int64
LastGeneratedID string
MaxDeletedEntryID string
EntriesAdded int64
FirstEntry XMessage
LastEntry XMessage
RecordedFirstEntryID string
}
XInfoStreamCmd
This type doesn't have documentation.
type XInfoStreamCmd struct {
baseCmd
val *XInfoStream
}
XInfoStreamConsumer
This type doesn't have documentation.
type XInfoStreamConsumer struct {
Name string
SeenTime time.Time
ActiveTime time.Time
PelCount int64
Pending []XInfoStreamConsumerPending
}
XInfoStreamConsumerPending
This type doesn't have documentation.
type XInfoStreamConsumerPending struct {
ID string
DeliveryTime time.Time
DeliveryCount int64
}
XInfoStreamFull
This type doesn't have documentation.
type XInfoStreamFull struct {
Length int64
RadixTreeKeys int64
RadixTreeNodes int64
LastGeneratedID string
MaxDeletedEntryID string
EntriesAdded int64
Entries []XMessage
Groups []XInfoStreamGroup
RecordedFirstEntryID string
}
XInfoStreamFullCmd
This type doesn't have documentation.
type XInfoStreamFullCmd struct {
baseCmd
val *XInfoStreamFull
}
XInfoStreamGroup
This type doesn't have documentation.
type XInfoStreamGroup struct {
Name string
LastDeliveredID string
EntriesRead int64
Lag int64
PelCount int64
Pending []XInfoStreamGroupPending
Consumers []XInfoStreamConsumer
}
XInfoStreamGroupPending
This type doesn't have documentation.
type XInfoStreamGroupPending struct {
ID string
Consumer string
DeliveryTime time.Time
DeliveryCount int64
}
XMessage
This type doesn't have documentation.
type XMessage struct {
ID string
Values map[string]interface{}
}
XMessageSliceCmd
This type doesn't have documentation.
type XMessageSliceCmd struct {
baseCmd
val []XMessage
}
XPending
This type doesn't have documentation.
type XPending struct {
Count int64
Lower string
Higher string
Consumers map[string]int64
}
XPendingCmd
This type doesn't have documentation.
type XPendingCmd struct {
baseCmd
val *XPending
}
XPendingExt
This type doesn't have documentation.
type XPendingExt struct {
ID string
Consumer string
Idle time.Duration
RetryCount int64
}
XPendingExtArgs
This type doesn't have documentation.
type XPendingExtArgs struct {
Stream string
Group string
Idle time.Duration
Start string
End string
Count int64
Consumer string
}
XPendingExtCmd
This type doesn't have documentation.
type XPendingExtCmd struct {
baseCmd
val []XPendingExt
}
XReadArgs
This type doesn't have documentation.
type XReadArgs struct {
Streams []string // list of streams and ids, e.g. stream1 stream2 id1 id2
Count int64
Block time.Duration
ID string
}
XReadGroupArgs
This type doesn't have documentation.
type XReadGroupArgs struct {
Group string
Consumer string
Streams []string // list of streams and ids, e.g. stream1 stream2 id1 id2
Count int64
Block time.Duration
NoAck bool
}
XStream
This type doesn't have documentation.
type XStream struct {
Stream string
Messages []XMessage
}
XStreamSliceCmd
This type doesn't have documentation.
type XStreamSliceCmd struct {
baseCmd
val []XStream
}
Z
Z represents sorted set member.
type Z struct {
Score float64
Member interface{}
}
ZAddArgs
ZAddArgs WARN: The GT, LT and NX options are mutually exclusive.
type ZAddArgs struct {
NX bool
XX bool
LT bool
GT bool
Ch bool
Members []Z
}
ZRangeArgs
ZRangeArgs is all the options of the ZRange command. In version> 6.2.0, you can replace the(cmd):
ZREVRANGE,
ZRANGEBYSCORE,
ZREVRANGEBYSCORE,
ZRANGEBYLEX,
ZREVRANGEBYLEX.
Please pay attention to your redis-server version.
Rev, ByScore, ByLex and Offset+Count options require redis-server 6.2.0 and higher.
type ZRangeArgs struct {
Key string
// When the ByScore option is provided, the open interval(exclusive) can be set.
// By default, the score intervals specified by <Start> and <Stop> are closed (inclusive).
// It is similar to the deprecated(6.2.0+) ZRangeByScore command.
// For example:
// ZRangeArgs{
// Key: "example-key",
// Start: "(3",
// Stop: 8,
// ByScore: true,
// }
// cmd: "ZRange example-key (3 8 ByScore" (3 < score <= 8).
//
// For the ByLex option, it is similar to the deprecated(6.2.0+) ZRangeByLex command.
// You can set the <Start> and <Stop> options as follows:
// ZRangeArgs{
// Key: "example-key",
// Start: "[abc",
// Stop: "(def",
// ByLex: true,
// }
// cmd: "ZRange example-key [abc (def ByLex"
//
// For normal cases (ByScore==false && ByLex==false), <Start> and <Stop> should be set to the index range (int).
// You can read the documentation for more information: https://redis.io/commands/zrange
Start interface{}
Stop interface{}
// The ByScore and ByLex options are mutually exclusive.
ByScore bool
ByLex bool
Rev bool
// limit offset count.
Offset int64
Count int64
}
ZRangeBy
This type doesn't have documentation.
type ZRangeBy struct {
Min, Max string
Offset, Count int64
}
ZSliceCmd
This type doesn't have documentation.
type ZSliceCmd struct {
baseCmd
val []Z
}
ZSliceWithKeyCmd
This type doesn't have documentation.
type ZSliceWithKeyCmd struct {
baseCmd
key string
val []Z
}
ZStore
ZStore is used as an arg to ZInter/ZInterStore and ZUnion/ZUnionStore.
type ZStore struct {
Keys []string
Weights []float64
// Can be SUM, MIN or MAX.
Aggregate string
}
ZWithKey
ZWithKey represents sorted set member including the name of the key where it was popped.
type ZWithKey struct {
Z
Key string
}
ZWithKeyCmd
This type doesn't have documentation.
type ZWithKeyCmd struct {
baseCmd
val *ZWithKey
}
DialHook, ProcessHook, ProcessPipelineHook
This type doesn't have documentation.
type (
DialHook func(ctx context.Context, network, addr string) (net.Conn, error)
ProcessHook func(ctx context.Context, cmd Cmder) error
ProcessPipelineHook func(ctx context.Context, cmds []Cmder) error
)
baseClient
This type doesn't have documentation.
type baseClient struct {
opt *Options
connPool pool.Pooler
onClose func() error // hook called when client is closed
}
baseCmd
This type doesn't have documentation.
type baseCmd struct {
ctx context.Context
args []interface{}
err error
keyPos int8
rawVal interface{}
_readTimeout *time.Duration
}
channel
This type doesn't have documentation.
type channel struct {
pubSub *PubSub
msgCh chan *Message
allCh chan interface{}
ping chan struct{}
chanSize int
chanSendTimeout time.Duration
checkInterval time.Duration
}
clusterNode
This type doesn't have documentation.
type clusterNode struct {
Client *Client
latency uint32 // atomic
generation uint32 // atomic
failing uint32 // atomic
// last time the latency measurement was performed for the node, stored in nanoseconds
// from epoch
lastLatencyMeasurement int64 // atomic
}
clusterNodes
This type doesn't have documentation.
type clusterNodes struct {
opt *ClusterOptions
mu sync.RWMutex
addrs []string
nodes map[string]*clusterNode
activeAddrs []string
closed bool
onNewNode []func(rdb *Client)
_generation uint32 // atomic
}
clusterSlot
This type doesn't have documentation.
type clusterSlot struct {
start, end int
nodes []*clusterNode
}
clusterSlotSlice
This type doesn't have documentation.
type clusterSlotSlice []*clusterSlot
clusterState
This type doesn't have documentation.
type clusterState struct {
nodes *clusterNodes
Masters []*clusterNode
Slaves []*clusterNode
slots []*clusterSlot
generation uint32
createdAt time.Time
}
clusterStateHolder
This type doesn't have documentation.
type clusterStateHolder struct {
load func(ctx context.Context) (*clusterState, error)
state atomic.Value
reloading uint32 // atomic
}
cmdable
This type doesn't have documentation.
type cmdable func(ctx context.Context, cmd Cmder) error
cmdsInfoCache
This type doesn't have documentation.
type cmdsInfoCache struct {
fn func(ctx context.Context) (map[string]*CommandInfo, error)
once internal.Once
cmds map[string]*CommandInfo
}
cmdsMap
This type doesn't have documentation.
type cmdsMap struct {
mu sync.Mutex
m map[*clusterNode][]Cmder
}
hooks
This type doesn't have documentation.
type hooks struct {
dial DialHook
process ProcessHook
pipeline ProcessPipelineHook
txPipeline ProcessPipelineHook
}
hooksMixin
This type doesn't have documentation.
type hooksMixin struct {
hooksMu *sync.Mutex
slice []Hook
initial hooks
current hooks
}
pipelineExecer
This type doesn't have documentation.
type pipelineExecer func(context.Context, []Cmder) error
pipelineProcessor
This type doesn't have documentation.
type pipelineProcessor func(context.Context, *pool.Conn, []Cmder) (bool, error)
queryOptions
This type doesn't have documentation.
type queryOptions struct {
q url.Values
err error
}
rendezvousWrapper
This type doesn't have documentation.
type rendezvousWrapper struct {
*rendezvous.Rendezvous
}
ringShard
This type doesn't have documentation.
type ringShard struct {
Client *Client
down int32
addr string
}
ringSharding
This type doesn't have documentation.
type ringSharding struct {
opt *RingOptions
mu sync.RWMutex
shards *ringShards
closed bool
hash ConsistentHash
numShard int
onNewNode []func(rdb *Client)
// ensures exclusive access to SetAddrs so there is no need
// to hold mu for the duration of potentially long shard creation
setAddrsMu sync.Mutex
}
ringShards
This type doesn't have documentation.
type ringShards struct {
m map[string]*ringShard
list []*ringShard
}
sentinelFailover
This type doesn't have documentation.
type sentinelFailover struct {
opt *FailoverOptions
sentinelAddrs []string
onFailover func(ctx context.Context, addr string)
onUpdate func(ctx context.Context)
mu sync.RWMutex
_masterAddr string
sentinel *SentinelClient
pubsub *PubSub
}
statefulCmdable
This type doesn't have documentation.
type statefulCmdable func(ctx context.Context, cmd Cmder) error
timeoutError
This type doesn't have documentation.
type timeoutError interface {
Timeout() bool
}
Functions
func FTAggregateQuery
func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery {
queryArgs := []interface{}{query}
if options != nil {
if options.Verbatim {
queryArgs = append(queryArgs, "VERBATIM")
}
if options.LoadAll && options.Load != nil {
panic("FT.AGGREGATE: LOADALL and LOAD are mutually exclusive")
}
if options.LoadAll {
queryArgs = append(queryArgs, "LOAD", "*")
}
if options.Load != nil {
queryArgs = append(queryArgs, "LOAD", len(options.Load))
for _, load := range options.Load {
queryArgs = append(queryArgs, load.Field)
if load.As != "" {
queryArgs = append(queryArgs, "AS", load.As)
}
}
}
if options.Timeout > 0 {
queryArgs = append(queryArgs, "TIMEOUT", options.Timeout)
}
if options.GroupBy != nil {
for _, groupBy := range options.GroupBy {
queryArgs = append(queryArgs, "GROUPBY", len(groupBy.Fields))
queryArgs = append(queryArgs, groupBy.Fields...)
for _, reducer := range groupBy.Reduce {
queryArgs = append(queryArgs, "REDUCE")
queryArgs = append(queryArgs, reducer.Reducer.String())
if reducer.Args != nil {
queryArgs = append(queryArgs, len(reducer.Args))
queryArgs = append(queryArgs, reducer.Args...)
} else {
queryArgs = append(queryArgs, 0)
}
if reducer.As != "" {
queryArgs = append(queryArgs, "AS", reducer.As)
}
}
}
}
if options.SortBy != nil {
queryArgs = append(queryArgs, "SORTBY")
sortByOptions := []interface{}{}
for _, sortBy := range options.SortBy {
sortByOptions = append(sortByOptions, sortBy.FieldName)
if sortBy.Asc && sortBy.Desc {
panic("FT.AGGREGATE: ASC and DESC are mutually exclusive")
}
if sortBy.Asc {
sortByOptions = append(sortByOptions, "ASC")
}
if sortBy.Desc {
sortByOptions = append(sortByOptions, "DESC")
}
}
queryArgs = append(queryArgs, len(sortByOptions))
queryArgs = append(queryArgs, sortByOptions...)
}
if options.SortByMax > 0 {
queryArgs = append(queryArgs, "MAX", options.SortByMax)
}
for _, apply := range options.Apply {
queryArgs = append(queryArgs, "APPLY", apply.Field)
if apply.As != "" {
queryArgs = append(queryArgs, "AS", apply.As)
}
}
if options.LimitOffset > 0 {
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset)
}
if options.Limit > 0 {
queryArgs = append(queryArgs, options.Limit)
}
if options.Filter != "" {
queryArgs = append(queryArgs, "FILTER", options.Filter)
}
if options.WithCursor {
queryArgs = append(queryArgs, "WITHCURSOR")
if options.WithCursorOptions != nil {
if options.WithCursorOptions.Count > 0 {
queryArgs = append(queryArgs, "COUNT", options.WithCursorOptions.Count)
}
if options.WithCursorOptions.MaxIdle > 0 {
queryArgs = append(queryArgs, "MAXIDLE", options.WithCursorOptions.MaxIdle)
}
}
}
if options.Params != nil {
queryArgs = append(queryArgs, "PARAMS", len(options.Params)*2)
for key, value := range options.Params {
queryArgs = append(queryArgs, key, value)
}
}
if options.DialectVersion > 0 {
queryArgs = append(queryArgs, "DIALECT", options.DialectVersion)
}
}
return queryArgs
}
Cognitive complexity: 74
, Cyclomatic complexity: 34
func FTSearchQuery
func FTSearchQuery(query string, options *FTSearchOptions) SearchQuery {
queryArgs := []interface{}{query}
if options != nil {
if options.NoContent {
queryArgs = append(queryArgs, "NOCONTENT")
}
if options.Verbatim {
queryArgs = append(queryArgs, "VERBATIM")
}
if options.NoStopWords {
queryArgs = append(queryArgs, "NOSTOPWORDS")
}
if options.WithScores {
queryArgs = append(queryArgs, "WITHSCORES")
}
if options.WithPayloads {
queryArgs = append(queryArgs, "WITHPAYLOADS")
}
if options.WithSortKeys {
queryArgs = append(queryArgs, "WITHSORTKEYS")
}
if options.Filters != nil {
for _, filter := range options.Filters {
queryArgs = append(queryArgs, "FILTER", filter.FieldName, filter.Min, filter.Max)
}
}
if options.GeoFilter != nil {
for _, geoFilter := range options.GeoFilter {
queryArgs = append(queryArgs, "GEOFILTER", geoFilter.FieldName, geoFilter.Longitude, geoFilter.Latitude, geoFilter.Radius, geoFilter.Unit)
}
}
if options.InKeys != nil {
queryArgs = append(queryArgs, "INKEYS", len(options.InKeys))
queryArgs = append(queryArgs, options.InKeys...)
}
if options.InFields != nil {
queryArgs = append(queryArgs, "INFIELDS", len(options.InFields))
queryArgs = append(queryArgs, options.InFields...)
}
if options.Return != nil {
queryArgs = append(queryArgs, "RETURN")
queryArgsReturn := []interface{}{}
for _, ret := range options.Return {
queryArgsReturn = append(queryArgsReturn, ret.FieldName)
if ret.As != "" {
queryArgsReturn = append(queryArgsReturn, "AS", ret.As)
}
}
queryArgs = append(queryArgs, len(queryArgsReturn))
queryArgs = append(queryArgs, queryArgsReturn...)
}
if options.Slop > 0 {
queryArgs = append(queryArgs, "SLOP", options.Slop)
}
if options.Timeout > 0 {
queryArgs = append(queryArgs, "TIMEOUT", options.Timeout)
}
if options.InOrder {
queryArgs = append(queryArgs, "INORDER")
}
if options.Language != "" {
queryArgs = append(queryArgs, "LANGUAGE", options.Language)
}
if options.Expander != "" {
queryArgs = append(queryArgs, "EXPANDER", options.Expander)
}
if options.Scorer != "" {
queryArgs = append(queryArgs, "SCORER", options.Scorer)
}
if options.ExplainScore {
queryArgs = append(queryArgs, "EXPLAINSCORE")
}
if options.Payload != "" {
queryArgs = append(queryArgs, "PAYLOAD", options.Payload)
}
if options.SortBy != nil {
queryArgs = append(queryArgs, "SORTBY")
for _, sortBy := range options.SortBy {
queryArgs = append(queryArgs, sortBy.FieldName)
if sortBy.Asc && sortBy.Desc {
panic("FT.SEARCH: ASC and DESC are mutually exclusive")
}
if sortBy.Asc {
queryArgs = append(queryArgs, "ASC")
}
if sortBy.Desc {
queryArgs = append(queryArgs, "DESC")
}
}
if options.SortByWithCount {
queryArgs = append(queryArgs, "WITHCOUNT")
}
}
if options.LimitOffset >= 0 && options.Limit > 0 {
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset, options.Limit)
}
if options.Params != nil {
queryArgs = append(queryArgs, "PARAMS", len(options.Params)*2)
for key, value := range options.Params {
queryArgs = append(queryArgs, key, value)
}
}
if options.DialectVersion > 0 {
queryArgs = append(queryArgs, "DIALECT", options.DialectVersion)
}
}
return queryArgs
}
Cognitive complexity: 77
, Cyclomatic complexity: 37
func HasErrorPrefix
HasErrorPrefix checks if the err is a Redis error and the message contains a prefix.
func HasErrorPrefix(err error, prefix string) bool {
var rErr Error
if !errors.As(err, &rErr) {
return false
}
msg := rErr.Error()
msg = strings.TrimPrefix(msg, "ERR ") // KVRocks adds such prefix
return strings.HasPrefix(msg, prefix)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func NewACLLogCmd
func NewACLLogCmd(ctx context.Context, args ...interface{}) *ACLLogCmd {
return &ACLLogCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewAggregateCmd
func NewAggregateCmd(ctx context.Context, args ...interface{}) *AggregateCmd {
return &AggregateCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewBFInfoCmd
func NewBFInfoCmd(ctx context.Context, args ...interface{}) *BFInfoCmd {
return &BFInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewBoolCmd
func NewBoolCmd(ctx context.Context, args ...interface{}) *BoolCmd {
return &BoolCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewBoolResult
NewBoolResult returns a BoolCmd initialised with val and err for testing.
func NewBoolResult(val bool, err error) *BoolCmd {
var cmd BoolCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewBoolSliceCmd
func NewBoolSliceCmd(ctx context.Context, args ...interface{}) *BoolSliceCmd {
return &BoolSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewBoolSliceResult
NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.
func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
var cmd BoolSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewCFInfoCmd
func NewCFInfoCmd(ctx context.Context, args ...interface{}) *CFInfoCmd {
return &CFInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewCMSInfoCmd
func NewCMSInfoCmd(ctx context.Context, args ...interface{}) *CMSInfoCmd {
return &CMSInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewClient
NewClient returns a client to the Redis Server specified by Options.
func NewClient(opt *Options) *Client {
opt.init()
c := Client{
baseClient: &baseClient{
opt: opt,
},
}
c.init()
c.connPool = newConnPool(opt, c.dialHook)
return &c
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func NewClientInfoCmd
func NewClientInfoCmd(ctx context.Context, args ...interface{}) *ClientInfoCmd {
return &ClientInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewClusterClient
NewClusterClient returns a Redis Cluster client as described in http://redis.io/topics/cluster-spec.
func NewClusterClient(opt *ClusterOptions) *ClusterClient {
opt.init()
c := &ClusterClient{
opt: opt,
nodes: newClusterNodes(opt),
}
c.state = newClusterStateHolder(c.loadState)
c.cmdsInfoCache = newCmdsInfoCache(c.cmdsInfo)
c.cmdable = c.Process
c.initHooks(hooks{
dial: nil,
process: c.process,
pipeline: c.processPipeline,
txPipeline: c.processTxPipeline,
})
return c
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func NewClusterLinksCmd
func NewClusterLinksCmd(ctx context.Context, args ...interface{}) *ClusterLinksCmd {
return &ClusterLinksCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewClusterShardsCmd
func NewClusterShardsCmd(ctx context.Context, args ...interface{}) *ClusterShardsCmd {
return &ClusterShardsCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewClusterSlotsCmd
func NewClusterSlotsCmd(ctx context.Context, args ...interface{}) *ClusterSlotsCmd {
return &ClusterSlotsCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewClusterSlotsCmdResult
NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.
func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
var cmd ClusterSlotsCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewCmd
func NewCmd(ctx context.Context, args ...interface{}) *Cmd {
return &Cmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewCmdResult
NewCmdResult returns a Cmd initialised with val and err for testing.
func NewCmdResult(val interface{}, err error) *Cmd {
var cmd Cmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func NewCommandsInfoCmd
func NewCommandsInfoCmd(ctx context.Context, args ...interface{}) *CommandsInfoCmd {
return &CommandsInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewCommandsInfoCmdResult
NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.
func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd {
var cmd CommandsInfoCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewDialer
NewDialer returns a function that will be used as the default dialer when none is specified in Options.Dialer.
func NewDialer(opt *Options) func(context.Context, string, string) (net.Conn, error) {
return func(ctx context.Context, network, addr string) (net.Conn, error) {
netDialer := &net.Dialer{
Timeout: opt.DialTimeout,
KeepAlive: 5 * time.Minute,
}
if opt.TLSConfig == nil {
return netDialer.DialContext(ctx, network, addr)
}
return tls.DialWithDialer(netDialer, network, addr, opt.TLSConfig)
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func NewDurationCmd
func NewDurationCmd(ctx context.Context, precision time.Duration, args ...interface{}) *DurationCmd {
return &DurationCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
precision: precision,
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewDurationResult
NewDurationResult returns a DurationCmd initialised with val and err for testing.
func NewDurationResult(val time.Duration, err error) *DurationCmd {
var cmd DurationCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewFTSynDumpCmd
func NewFTSynDumpCmd(ctx context.Context, args ...interface{}) *FTSynDumpCmd {
return &FTSynDumpCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewFailoverClient
NewFailoverClient returns a Redis client that uses Redis Sentinel for automatic failover. It's safe for concurrent use by multiple goroutines.
func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
if failoverOpt.RouteByLatency {
panic("to route commands by latency, use NewFailoverClusterClient")
}
if failoverOpt.RouteRandomly {
panic("to route commands randomly, use NewFailoverClusterClient")
}
sentinelAddrs := make([]string, len(failoverOpt.SentinelAddrs))
copy(sentinelAddrs, failoverOpt.SentinelAddrs)
rand.Shuffle(len(sentinelAddrs), func(i, j int) {
sentinelAddrs[i], sentinelAddrs[j] = sentinelAddrs[j], sentinelAddrs[i]
})
failover := &sentinelFailover{
opt: failoverOpt,
sentinelAddrs: sentinelAddrs,
}
opt := failoverOpt.clientOptions()
opt.Dialer = masterReplicaDialer(failover)
opt.init()
var connPool *pool.ConnPool
rdb := &Client{
baseClient: &baseClient{
opt: opt,
},
}
rdb.init()
connPool = newConnPool(opt, rdb.dialHook)
rdb.connPool = connPool
rdb.onClose = failover.Close
failover.mu.Lock()
failover.onFailover = func(ctx context.Context, addr string) {
_ = connPool.Filter(func(cn *pool.Conn) bool {
return cn.RemoteAddr().String() != addr
})
}
failover.mu.Unlock()
return rdb
}
Cognitive complexity: 10
, Cyclomatic complexity: 3
func NewFailoverClusterClient
NewFailoverClusterClient returns a client that supports routing read-only commands to a replica node.
func NewFailoverClusterClient(failoverOpt *FailoverOptions) *ClusterClient {
sentinelAddrs := make([]string, len(failoverOpt.SentinelAddrs))
copy(sentinelAddrs, failoverOpt.SentinelAddrs)
failover := &sentinelFailover{
opt: failoverOpt,
sentinelAddrs: sentinelAddrs,
}
opt := failoverOpt.clusterOptions()
opt.ClusterSlots = func(ctx context.Context) ([]ClusterSlot, error) {
masterAddr, err := failover.MasterAddr(ctx)
if err != nil {
return nil, err
}
nodes := []ClusterNode{{
Addr: masterAddr,
}}
replicaAddrs, err := failover.replicaAddrs(ctx, false)
if err != nil {
return nil, err
}
for _, replicaAddr := range replicaAddrs {
nodes = append(nodes, ClusterNode{
Addr: replicaAddr,
})
}
slots := []ClusterSlot{
{
Start: 0,
End: 16383,
Nodes: nodes,
},
}
return slots, nil
}
c := NewClusterClient(opt)
failover.mu.Lock()
failover.onUpdate = func(ctx context.Context) {
c.ReloadState(ctx)
}
failover.mu.Unlock()
return c
}
Cognitive complexity: 15
, Cyclomatic complexity: 4
func NewFloatCmd
func NewFloatCmd(ctx context.Context, args ...interface{}) *FloatCmd {
return &FloatCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewFloatResult
NewFloatResult returns a FloatCmd initialised with val and err for testing.
func NewFloatResult(val float64, err error) *FloatCmd {
var cmd FloatCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewFloatSliceCmd
func NewFloatSliceCmd(ctx context.Context, args ...interface{}) *FloatSliceCmd {
return &FloatSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewFunctionListCmd
func NewFunctionListCmd(ctx context.Context, args ...interface{}) *FunctionListCmd {
return &FunctionListCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewFunctionStatsCmd
func NewFunctionStatsCmd(ctx context.Context, args ...interface{}) *FunctionStatsCmd {
return &FunctionStatsCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewGeoLocationCmd
func NewGeoLocationCmd(ctx context.Context, q *GeoRadiusQuery, args ...interface{}) *GeoLocationCmd {
return &GeoLocationCmd{
baseCmd: baseCmd{
ctx: ctx,
args: geoLocationArgs(q, args...),
},
q: q,
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewGeoLocationCmdResult
NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.
func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
var cmd GeoLocationCmd
cmd.locations = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewGeoPosCmd
func NewGeoPosCmd(ctx context.Context, args ...interface{}) *GeoPosCmd {
return &GeoPosCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewGeoPosCmdResult
NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.
func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd {
var cmd GeoPosCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewGeoSearchLocationCmd
func NewGeoSearchLocationCmd(
ctx context.Context, opt *GeoSearchLocationQuery, args ...interface{},
) *GeoSearchLocationCmd {
return &GeoSearchLocationCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
opt: opt,
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewInfoCmd
func NewInfoCmd(ctx context.Context, args ...interface{}) *InfoCmd {
return &InfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewIntCmd
func NewIntCmd(ctx context.Context, args ...interface{}) *IntCmd {
return &IntCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewIntPointerSliceCmd
NewIntPointerSliceCmd initialises an IntPointerSliceCmd
func NewIntPointerSliceCmd(ctx context.Context, args ...interface{}) *IntPointerSliceCmd {
return &IntPointerSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewIntResult
NewIntResult returns an IntCmd initialised with val and err for testing.
func NewIntResult(val int64, err error) *IntCmd {
var cmd IntCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewIntSliceCmd
func NewIntSliceCmd(ctx context.Context, args ...interface{}) *IntSliceCmd {
return &IntSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewJSONSliceCmd
func NewJSONSliceCmd(ctx context.Context, args ...interface{}) *JSONSliceCmd {
return &JSONSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewKeyFlagsCmd
func NewKeyFlagsCmd(ctx context.Context, args ...interface{}) *KeyFlagsCmd {
return &KeyFlagsCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewKeyValueSliceCmd
func NewKeyValueSliceCmd(ctx context.Context, args ...interface{}) *KeyValueSliceCmd {
return &KeyValueSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewKeyValuesCmd
func NewKeyValuesCmd(ctx context.Context, args ...interface{}) *KeyValuesCmd {
return &KeyValuesCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewLCSCmd
func NewLCSCmd(ctx context.Context, q *LCSQuery) *LCSCmd {
args := make([]interface{}, 3, 7)
args[0] = "lcs"
args[1] = q.Key1
args[2] = q.Key2
cmd := &LCSCmd{readType: 1}
if q.Len {
cmd.readType = 2
args = append(args, "len")
} else if q.Idx {
cmd.readType = 3
args = append(args, "idx")
if q.MinMatchLen != 0 {
args = append(args, "minmatchlen", q.MinMatchLen)
}
if q.WithMatchLen {
args = append(args, "withmatchlen")
}
}
cmd.baseCmd = baseCmd{
ctx: ctx,
args: args,
}
return cmd
}
Cognitive complexity: 11
, Cyclomatic complexity: 5
func NewMapMapStringInterfaceCmd
func NewMapMapStringInterfaceCmd(ctx context.Context, args ...interface{}) *MapMapStringInterfaceCmd {
return &MapMapStringInterfaceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewMapStringIntCmd
func NewMapStringIntCmd(ctx context.Context, args ...interface{}) *MapStringIntCmd {
return &MapStringIntCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewMapStringIntCmdResult
NewMapStringIntCmdResult returns a MapStringIntCmd initialised with val and err for testing.
func NewMapStringIntCmdResult(val map[string]int64, err error) *MapStringIntCmd {
var cmd MapStringIntCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewMapStringInterfaceCmd
func NewMapStringInterfaceCmd(ctx context.Context, args ...interface{}) *MapStringInterfaceCmd {
return &MapStringInterfaceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewMapStringInterfaceSliceCmd
func NewMapStringInterfaceSliceCmd(ctx context.Context, args ...interface{}) *MapStringInterfaceSliceCmd {
return &MapStringInterfaceSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewMapStringSliceInterfaceCmd
func NewMapStringSliceInterfaceCmd(ctx context.Context, args ...interface{}) *MapStringSliceInterfaceCmd {
return &MapStringSliceInterfaceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewMapStringStringCmd
func NewMapStringStringCmd(ctx context.Context, args ...interface{}) *MapStringStringCmd {
return &MapStringStringCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewMapStringStringResult
NewMapStringStringResult returns a MapStringStringCmd initialised with val and err for testing.
func NewMapStringStringResult(val map[string]string, err error) *MapStringStringCmd {
var cmd MapStringStringCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewMapStringStringSliceCmd
func NewMapStringStringSliceCmd(ctx context.Context, args ...interface{}) *MapStringStringSliceCmd {
return &MapStringStringSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewRankWithScoreCmd
func NewRankWithScoreCmd(ctx context.Context, args ...interface{}) *RankWithScoreCmd {
return &RankWithScoreCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewRing
func NewRing(opt *RingOptions) *Ring {
opt.init()
hbCtx, hbCancel := context.WithCancel(context.Background())
ring := Ring{
opt: opt,
sharding: newRingSharding(opt),
heartbeatCancelFn: hbCancel,
}
ring.cmdsInfoCache = newCmdsInfoCache(ring.cmdsInfo)
ring.cmdable = ring.Process
ring.initHooks(hooks{
process: ring.process,
pipeline: func(ctx context.Context, cmds []Cmder) error {
return ring.generalProcessPipeline(ctx, cmds, false)
},
txPipeline: func(ctx context.Context, cmds []Cmder) error {
return ring.generalProcessPipeline(ctx, cmds, true)
},
})
go ring.sharding.Heartbeat(hbCtx, opt.HeartbeatFrequency)
return &ring
}
Cognitive complexity: 4
, Cyclomatic complexity: 1
func NewScanCmd
func NewScanCmd(ctx context.Context, process cmdable, args ...interface{}) *ScanCmd {
return &ScanCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
process: process,
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewScanCmdResult
NewScanCmdResult returns a ScanCmd initialised with val and err for testing.
func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
var cmd ScanCmd
cmd.page = keys
cmd.cursor = cursor
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewScript
func NewScript(src string) *Script {
h := sha1.New()
_, _ = io.WriteString(h, src)
return &Script{
src: src,
hash: hex.EncodeToString(h.Sum(nil)),
}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func NewSentinelClient
func NewSentinelClient(opt *Options) *SentinelClient {
opt.init()
c := &SentinelClient{
baseClient: &baseClient{
opt: opt,
},
}
c.initHooks(hooks{
dial: c.baseClient.dial,
process: c.baseClient.process,
})
c.connPool = newConnPool(opt, c.dialHook)
return c
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewSliceCmd
func NewSliceCmd(ctx context.Context, args ...interface{}) *SliceCmd {
return &SliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewSliceResult
NewSliceResult returns a SliceCmd initialised with val and err for testing.
func NewSliceResult(val []interface{}, err error) *SliceCmd {
var cmd SliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func NewSlowLogCmd
func NewSlowLogCmd(ctx context.Context, args ...interface{}) *SlowLogCmd {
return &SlowLogCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewStatusCmd
func NewStatusCmd(ctx context.Context, args ...interface{}) *StatusCmd {
return &StatusCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewStatusResult
NewStatusResult returns a StatusCmd initialised with val and err for testing.
func NewStatusResult(val string, err error) *StatusCmd {
var cmd StatusCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewStringCmd
func NewStringCmd(ctx context.Context, args ...interface{}) *StringCmd {
return &StringCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewStringResult
NewStringResult returns a StringCmd initialised with val and err for testing.
func NewStringResult(val string, err error) *StringCmd {
var cmd StringCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewStringSliceCmd
func NewStringSliceCmd(ctx context.Context, args ...interface{}) *StringSliceCmd {
return &StringSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewStringSliceResult
NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing.
func NewStringSliceResult(val []string, err error) *StringSliceCmd {
var cmd StringSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewStringStructMapCmd
func NewStringStructMapCmd(ctx context.Context, args ...interface{}) *StringStructMapCmd {
return &StringStructMapCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewTDigestInfoCmd
func NewTDigestInfoCmd(ctx context.Context, args ...interface{}) *TDigestInfoCmd {
return &TDigestInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewTimeCmd
func NewTimeCmd(ctx context.Context, args ...interface{}) *TimeCmd {
return &TimeCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewTimeCmdResult
NewTimeCmdResult returns a TimeCmd initialised with val and err for testing.
func NewTimeCmdResult(val time.Time, err error) *TimeCmd {
var cmd TimeCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewTopKInfoCmd
func NewTopKInfoCmd(ctx context.Context, args ...interface{}) *TopKInfoCmd {
return &TopKInfoCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewUniversalClient
NewUniversalClient returns a new multi client. The type of the returned client depends on the following conditions:
- If the MasterName option is specified, a sentinel-backed FailoverClient is returned.
- if the number of Addrs is two or more, a ClusterClient is returned.
- Otherwise, a single-node Client is returned.
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
if opts.MasterName != "" {
return NewFailoverClient(opts.Failover())
} else if len(opts.Addrs) > 1 {
return NewClusterClient(opts.Cluster())
}
return NewClient(opts.Simple())
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func NewXAutoClaimCmd
func NewXAutoClaimCmd(ctx context.Context, args ...interface{}) *XAutoClaimCmd {
return &XAutoClaimCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXAutoClaimJustIDCmd
func NewXAutoClaimJustIDCmd(ctx context.Context, args ...interface{}) *XAutoClaimJustIDCmd {
return &XAutoClaimJustIDCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXInfoConsumersCmd
func NewXInfoConsumersCmd(ctx context.Context, stream string, group string) *XInfoConsumersCmd {
return &XInfoConsumersCmd{
baseCmd: baseCmd{
ctx: ctx,
args: []interface{}{"xinfo", "consumers", stream, group},
},
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 1
func NewXInfoGroupsCmd
func NewXInfoGroupsCmd(ctx context.Context, stream string) *XInfoGroupsCmd {
return &XInfoGroupsCmd{
baseCmd: baseCmd{
ctx: ctx,
args: []interface{}{"xinfo", "groups", stream},
},
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 1
func NewXInfoStreamCmd
func NewXInfoStreamCmd(ctx context.Context, stream string) *XInfoStreamCmd {
return &XInfoStreamCmd{
baseCmd: baseCmd{
ctx: ctx,
args: []interface{}{"xinfo", "stream", stream},
},
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 1
func NewXInfoStreamFullCmd
func NewXInfoStreamFullCmd(ctx context.Context, args ...interface{}) *XInfoStreamFullCmd {
return &XInfoStreamFullCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXMessageSliceCmd
func NewXMessageSliceCmd(ctx context.Context, args ...interface{}) *XMessageSliceCmd {
return &XMessageSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXMessageSliceCmdResult
NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing.
func NewXMessageSliceCmdResult(val []XMessage, err error) *XMessageSliceCmd {
var cmd XMessageSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewXPendingCmd
func NewXPendingCmd(ctx context.Context, args ...interface{}) *XPendingCmd {
return &XPendingCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXPendingExtCmd
func NewXPendingExtCmd(ctx context.Context, args ...interface{}) *XPendingExtCmd {
return &XPendingExtCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXPendingResult
NewXPendingResult returns a XPendingCmd initialised with val and err for testing.
func NewXPendingResult(val *XPending, err error) *XPendingCmd {
var cmd XPendingCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewXStreamSliceCmd
func NewXStreamSliceCmd(ctx context.Context, args ...interface{}) *XStreamSliceCmd {
return &XStreamSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewXStreamSliceCmdResult
NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing.
func NewXStreamSliceCmdResult(val []XStream, err error) *XStreamSliceCmd {
var cmd XStreamSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewZSliceCmd
func NewZSliceCmd(ctx context.Context, args ...interface{}) *ZSliceCmd {
return &ZSliceCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewZSliceCmdResult
NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing.
func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
var cmd ZSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func NewZSliceWithKeyCmd
func NewZSliceWithKeyCmd(ctx context.Context, args ...interface{}) *ZSliceWithKeyCmd {
return &ZSliceWithKeyCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewZWithKeyCmd
func NewZWithKeyCmd(ctx context.Context, args ...interface{}) *ZWithKeyCmd {
return &ZWithKeyCmd{
baseCmd: baseCmd{
ctx: ctx,
args: args,
},
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func NewZWithKeyCmdResult
NewZWithKeyCmdResult returns a ZWithKeyCmd initialised with val and err for testing.
func NewZWithKeyCmdResult(val *ZWithKey, err error) *ZWithKeyCmd {
var cmd ZWithKeyCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func ParseClusterURL
ParseClusterURL parses a URL into ClusterOptions that can be used to connect to Redis. The URL must be in the form:
redis://<user>:<password>@<host>:<port>
or
rediss://<user>:<password>@<host>:<port>
To add additional addresses, specify the query parameter, "addr" one or more times. e.g:
redis://<user>:<password>@<host>:<port>?addr=<host2>:<port2>&addr=<host3>:<port3>
or
rediss://<user>:<password>@<host>:<port>?addr=<host2>:<port2>&addr=<host3>:<port3>
Most Option fields can be set using query parameters, with the following restrictions:
- field names are mapped using snake-case conversion: to set MaxRetries, use max_retries
- only scalar type fields are supported (bool, int, time.Duration)
- for time.Duration fields, values must be a valid input for time.ParseDuration(); additionally a plain integer as value (i.e. without unit) is interpreted as seconds
- to disable a duration field, use value less than or equal to 0; to use the default value, leave the value blank or remove the parameter
- only the last value is interpreted if a parameter is given multiple times
- fields "network", "addr", "username" and "password" can only be set using other URL attributes (scheme, host, userinfo, resp.), query parameters using these names will be treated as unknown parameters
- unknown parameter names will result in an error
Example:
redis://user:password@localhost:6789?dial_timeout=3&read_timeout=6s&addr=localhost:6790&addr=localhost:6791
is equivalent to:
&ClusterOptions{
Addr: ["localhost:6789", "localhost:6790", "localhost:6791"]
DialTimeout: 3 * time.Second, // no time unit = seconds
ReadTimeout: 6 * time.Second,
}
func ParseClusterURL(redisURL string) (*ClusterOptions, error) {
o := &ClusterOptions{}
u, err := url.Parse(redisURL)
if err != nil {
return nil, err
}
// add base URL to the array of addresses
// more addresses may be added through the URL params
h, p := getHostPortWithDefaults(u)
o.Addrs = append(o.Addrs, net.JoinHostPort(h, p))
// setup username, password, and other configurations
o, err = setupClusterConn(u, h, o)
if err != nil {
return nil, err
}
return o, nil
}
Cognitive complexity: 5
, Cyclomatic complexity: 3
func ParseURL
ParseURL parses a URL into Options that can be used to connect to Redis. Scheme is required. There are two connection types: by tcp socket and by unix socket. Tcp connection:
redis://<user>:<password>@<host>:<port>/<db_number>
Unix connection:
unix://<user>:<password>@</path/to/redis.sock>?db=<db_number>
Most Option fields can be set using query parameters, with the following restrictions:
- field names are mapped using snake-case conversion: to set MaxRetries, use max_retries
- only scalar type fields are supported (bool, int, time.Duration)
- for time.Duration fields, values must be a valid input for time.ParseDuration(); additionally a plain integer as value (i.e. without unit) is interpreted as seconds
- to disable a duration field, use value less than or equal to 0; to use the default value, leave the value blank or remove the parameter
- only the last value is interpreted if a parameter is given multiple times
- fields "network", "addr", "username" and "password" can only be set using other URL attributes (scheme, host, userinfo, resp.), query parameters using these names will be treated as unknown parameters
- unknown parameter names will result in an error
Examples:
redis://user:password@localhost:6789/3?dial_timeout=3&db=1&read_timeout=6s&max_retries=2
is equivalent to:
&Options{
Network: "tcp",
Addr: "localhost:6789",
DB: 1, // path "/3" was overridden by "&db=1"
DialTimeout: 3 * time.Second, // no time unit = seconds
ReadTimeout: 6 * time.Second,
MaxRetries: 2,
}
func ParseURL(redisURL string) (*Options, error) {
u, err := url.Parse(redisURL)
if err != nil {
return nil, err
}
switch u.Scheme {
case "redis", "rediss":
return setupTCPConn(u)
case "unix":
return setupUnixConn(u)
default:
return nil, fmt.Errorf("redis: invalid URL scheme: %s", u.Scheme)
}
}
Cognitive complexity: 6
, Cyclomatic complexity: 5
func ProcessAggregateResult
func ProcessAggregateResult(data []interface{}) (*FTAggregateResult, error) {
if len(data) == 0 {
return nil, fmt.Errorf("no data returned")
}
total, ok := data[0].(int64)
if !ok {
return nil, fmt.Errorf("invalid total format")
}
rows := make([]AggregateRow, 0, len(data)-1)
for _, row := range data[1:] {
fields, ok := row.([]interface{})
if !ok {
return nil, fmt.Errorf("invalid row format")
}
rowMap := make(map[string]interface{})
for i := 0; i < len(fields); i += 2 {
key, ok := fields[i].(string)
if !ok {
return nil, fmt.Errorf("invalid field key format")
}
value := fields[i+1]
rowMap[key] = value
}
rows = append(rows, AggregateRow{Fields: rowMap})
}
result := &FTAggregateResult{
Total: int(total),
Rows: rows,
}
return result, nil
}
Cognitive complexity: 18
, Cyclomatic complexity: 7
func SetLogger
SetLogger set custom log
func SetLogger(logger internal.Logging) {
internal.Logger = logger
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func Version
Version is the current release version.
func Version() string {
return "9.6.2"
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func WithChannelHealthCheckInterval
WithChannelHealthCheckInterval specifies the health check interval. PubSub will ping Redis Server if it does not receive any messages within the interval. To disable health check, use zero interval.
The default is 3 seconds.
func WithChannelHealthCheckInterval(d time.Duration) ChannelOption {
return func(c *channel) {
c.checkInterval = d
}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func WithChannelSendTimeout
WithChannelSendTimeout specifies the channel send timeout after which the message is dropped.
The default is 60 seconds.
func WithChannelSendTimeout(d time.Duration) ChannelOption {
return func(c *channel) {
c.chanSendTimeout = d
}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func WithChannelSize
WithChannelSize specifies the Go chan size that is used to buffer incoming messages.
The default is 100 messages.
func WithChannelSize(size int) ChannelOption {
return func(c *channel) {
c.chanSize = size
}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func WithLibraryName
WithLibraryName returns a valid LibraryInfo with library name only.
func WithLibraryName(libName string) LibraryInfo {
return LibraryInfo{LibName: &libName}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func WithLibraryVersion
WithLibraryVersion returns a valid LibraryInfo with library version only.
func WithLibraryVersion(libVer string) LibraryInfo {
return LibraryInfo{LibVer: &libVer}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*AggregateCmd) RawResult
func (cmd *AggregateCmd) RawResult() (interface{}, error) {
return cmd.rawVal, cmd.err
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*AggregateCmd) RawVal
func (cmd *AggregateCmd) RawVal() interface{} {
return cmd.rawVal
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Client) Conn
func (c *Client) Conn() *Conn {
return newConn(c.opt, pool.NewStickyConnPool(c.connPool))
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*Client) WithTimeout
func (c *Client) WithTimeout(timeout time.Duration) *Client {
clone := *c
clone.baseClient = c.baseClient.withTimeout(timeout)
clone.init()
return &clone
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ClusterClient) Do
Do create a Cmd from the args and processes the cmd.
func (c *ClusterClient) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*ClusterClient) ForEachMaster
ForEachMaster concurrently calls the fn on each master node in the cluster. It returns the first error if any.
func (c *ClusterClient) ForEachMaster(
ctx context.Context,
fn func(ctx context.Context, client *Client) error,
) error {
state, err := c.state.ReloadOrGet(ctx)
if err != nil {
return err
}
var wg sync.WaitGroup
errCh := make(chan error, 1)
for _, master := range state.Masters {
wg.Add(1)
go func(node *clusterNode) {
defer wg.Done()
err := fn(ctx, node.Client)
if err != nil {
select {
case errCh <- err:
default:
}
}
}(master)
}
wg.Wait()
select {
case err := <-errCh:
return err
default:
return nil
}
}
Cognitive complexity: 12
, Cyclomatic complexity: 6
func (*ClusterClient) ForEachShard
ForEachShard concurrently calls the fn on each known node in the cluster. It returns the first error if any.
func (c *ClusterClient) ForEachShard(
ctx context.Context,
fn func(ctx context.Context, client *Client) error,
) error {
state, err := c.state.ReloadOrGet(ctx)
if err != nil {
return err
}
var wg sync.WaitGroup
errCh := make(chan error, 1)
worker := func(node *clusterNode) {
defer wg.Done()
err := fn(ctx, node.Client)
if err != nil {
select {
case errCh <- err:
default:
}
}
}
for _, node := range state.Masters {
wg.Add(1)
go worker(node)
}
for _, node := range state.Slaves {
wg.Add(1)
go worker(node)
}
wg.Wait()
select {
case err := <-errCh:
return err
default:
return nil
}
}
Cognitive complexity: 15
, Cyclomatic complexity: 7
func (*ClusterClient) ForEachSlave
ForEachSlave concurrently calls the fn on each slave node in the cluster. It returns the first error if any.
func (c *ClusterClient) ForEachSlave(
ctx context.Context,
fn func(ctx context.Context, client *Client) error,
) error {
state, err := c.state.ReloadOrGet(ctx)
if err != nil {
return err
}
var wg sync.WaitGroup
errCh := make(chan error, 1)
for _, slave := range state.Slaves {
wg.Add(1)
go func(node *clusterNode) {
defer wg.Done()
err := fn(ctx, node.Client)
if err != nil {
select {
case errCh <- err:
default:
}
}
}(slave)
}
wg.Wait()
select {
case err := <-errCh:
return err
default:
return nil
}
}
Cognitive complexity: 12
, Cyclomatic complexity: 6
func (*ClusterClient) MasterForKey
MasterForKey return a client to the master node for a particular key.
func (c *ClusterClient) MasterForKey(ctx context.Context, key string) (*Client, error) {
slot := hashtag.Slot(key)
node, err := c.slotMasterNode(ctx, slot)
if err != nil {
return nil, err
}
return node.Client, err
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ClusterClient) Options
Options returns read-only Options that were used to create the client.
func (c *ClusterClient) Options() *ClusterOptions {
return c.opt
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ClusterClient) PSubscribe
PSubscribe subscribes the client to the given patterns. Patterns can be omitted to create empty subscription.
func (c *ClusterClient) PSubscribe(ctx context.Context, channels ...string) *PubSub {
pubsub := c.pubSub()
if len(channels) > 0 {
_ = pubsub.PSubscribe(ctx, channels...)
}
return pubsub
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ClusterClient) Pipeline
func (c *ClusterClient) Pipeline() Pipeliner {
pipe := Pipeline{
exec: pipelineExecer(c.processPipelineHook),
}
pipe.init()
return &pipe
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*ClusterClient) Pipelined
func (c *ClusterClient) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error) {
return c.Pipeline().Pipelined(ctx, fn)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ClusterClient) PoolStats
PoolStats returns accumulated connection pool stats.
func (c *ClusterClient) PoolStats() *PoolStats {
var acc PoolStats
state, _ := c.state.Get(context.TODO())
if state == nil {
return &acc
}
for _, node := range state.Masters {
s := node.Client.connPool.Stats()
acc.Hits += s.Hits
acc.Misses += s.Misses
acc.Timeouts += s.Timeouts
acc.TotalConns += s.TotalConns
acc.IdleConns += s.IdleConns
acc.StaleConns += s.StaleConns
}
for _, node := range state.Slaves {
s := node.Client.connPool.Stats()
acc.Hits += s.Hits
acc.Misses += s.Misses
acc.Timeouts += s.Timeouts
acc.TotalConns += s.TotalConns
acc.IdleConns += s.IdleConns
acc.StaleConns += s.StaleConns
}
return &acc
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (*ClusterClient) Process
func (c *ClusterClient) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd)
cmd.SetErr(err)
return err
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ClusterClient) ReloadState
ReloadState reloads cluster state. If available it calls ClusterSlots func to get cluster slots information.
func (c *ClusterClient) ReloadState(ctx context.Context) {
c.state.LazyReload()
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ClusterClient) SSubscribe
SSubscribe Subscribes the client to the specified shard channels.
func (c *ClusterClient) SSubscribe(ctx context.Context, channels ...string) *PubSub {
pubsub := c.pubSub()
if len(channels) > 0 {
_ = pubsub.SSubscribe(ctx, channels...)
}
return pubsub
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ClusterClient) ScriptExists
func (c *ClusterClient) ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd {
args := make([]interface{}, 2+len(hashes))
args[0] = "script"
args[1] = "exists"
for i, hash := range hashes {
args[2+i] = hash
}
cmd := NewBoolSliceCmd(ctx, args...)
result := make([]bool, len(hashes))
for i := range result {
result[i] = true
}
_ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error {
var mu sync.Mutex
err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error {
val, err := shard.ScriptExists(ctx, hashes...).Result()
if err != nil {
return err
}
mu.Lock()
for i, v := range val {
result[i] = result[i] && v
}
mu.Unlock()
return nil
})
if err != nil {
cmd.SetErr(err)
} else {
cmd.val = result
}
return nil
})
return cmd
}
Cognitive complexity: 18
, Cyclomatic complexity: 7
func (*ClusterClient) ScriptFlush
func (c *ClusterClient) ScriptFlush(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "script", "flush")
_ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error {
err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error {
return shard.ScriptFlush(ctx).Err()
})
if err != nil {
cmd.SetErr(err)
}
return nil
})
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (*ClusterClient) ScriptLoad
func (c *ClusterClient) ScriptLoad(ctx context.Context, script string) *StringCmd {
cmd := NewStringCmd(ctx, "script", "load", script)
_ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error {
var mu sync.Mutex
err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error {
val, err := shard.ScriptLoad(ctx, script).Result()
if err != nil {
return err
}
mu.Lock()
if cmd.Val() == "" {
cmd.val = val
}
mu.Unlock()
return nil
})
if err != nil {
cmd.SetErr(err)
}
return nil
})
return cmd
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (*ClusterClient) SlaveForKey
SlaveForKey gets a client for a replica node to run any command on it. This is especially useful if we want to run a particular lua script which has only read only commands on the replica. This is because other redis commands generally have a flag that points that they are read only and automatically run on the replica nodes if ClusterOptions.ReadOnly flag is set to true.
func (c *ClusterClient) SlaveForKey(ctx context.Context, key string) (*Client, error) {
state, err := c.state.Get(ctx)
if err != nil {
return nil, err
}
slot := hashtag.Slot(key)
node, err := c.slotReadOnlyNode(state, slot)
if err != nil {
return nil, err
}
return node.Client, err
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func (*ClusterClient) Subscribe
Subscribe subscribes the client to the specified channels. Channels can be omitted to create empty subscription.
func (c *ClusterClient) Subscribe(ctx context.Context, channels ...string) *PubSub {
pubsub := c.pubSub()
if len(channels) > 0 {
_ = pubsub.Subscribe(ctx, channels...)
}
return pubsub
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ClusterClient) TxPipeline
TxPipeline acts like Pipeline, but wraps queued commands with MULTI/EXEC.
func (c *ClusterClient) TxPipeline() Pipeliner {
pipe := Pipeline{
exec: func(ctx context.Context, cmds []Cmder) error {
cmds = wrapMultiExec(ctx, cmds)
return c.processTxPipelineHook(ctx, cmds)
},
}
pipe.init()
return &pipe
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (*ClusterClient) TxPipelined
func (c *ClusterClient) TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error) {
return c.TxPipeline().Pipelined(ctx, fn)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ClusterClient) Watch
func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...string) error {
if len(keys) == 0 {
return fmt.Errorf("redis: Watch requires at least one key")
}
slot := hashtag.Slot(keys[0])
for _, key := range keys[1:] {
if hashtag.Slot(key) != slot {
err := fmt.Errorf("redis: Watch requires all keys to be in the same slot")
return err
}
}
node, err := c.slotMasterNode(ctx, slot)
if err != nil {
return err
}
for attempt := 0; attempt <= c.opt.MaxRedirects; attempt++ {
if attempt > 0 {
if err := internal.Sleep(ctx, c.retryBackoff(attempt)); err != nil {
return err
}
}
err = node.Client.Watch(ctx, fn, keys...)
if err == nil {
break
}
moved, ask, addr := isMovedError(err)
if moved || ask {
node, err = c.nodes.GetOrCreate(addr)
if err != nil {
return err
}
continue
}
if isReadOnly := isReadOnlyError(err); isReadOnly || err == pool.ErrClosed {
if isReadOnly {
c.state.LazyReload()
}
node, err = c.slotMasterNode(ctx, slot)
if err != nil {
return err
}
continue
}
if shouldRetry(err, true) {
continue
}
return err
}
return err
}
Cognitive complexity: 29
, Cyclomatic complexity: 17
func (*Cmd) Bool
func (cmd *Cmd) Bool() (bool, error) {
if cmd.err != nil {
return false, cmd.err
}
return toBool(cmd.val)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*Cmd) BoolSlice
func (cmd *Cmd) BoolSlice() ([]bool, error) {
slice, err := cmd.Slice()
if err != nil {
return nil, err
}
bools := make([]bool, len(slice))
for i, iface := range slice {
val, err := toBool(iface)
if err != nil {
return nil, err
}
bools[i] = val
}
return bools, nil
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) Float32
func (cmd *Cmd) Float32() (float32, error) {
if cmd.err != nil {
return 0, cmd.err
}
return toFloat32(cmd.val)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*Cmd) Float32Slice
func (cmd *Cmd) Float32Slice() ([]float32, error) {
slice, err := cmd.Slice()
if err != nil {
return nil, err
}
floats := make([]float32, len(slice))
for i, iface := range slice {
val, err := toFloat32(iface)
if err != nil {
return nil, err
}
floats[i] = val
}
return floats, nil
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) Float64
func (cmd *Cmd) Float64() (float64, error) {
if cmd.err != nil {
return 0, cmd.err
}
return toFloat64(cmd.val)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*Cmd) Float64Slice
func (cmd *Cmd) Float64Slice() ([]float64, error) {
slice, err := cmd.Slice()
if err != nil {
return nil, err
}
floats := make([]float64, len(slice))
for i, iface := range slice {
val, err := toFloat64(iface)
if err != nil {
return nil, err
}
floats[i] = val
}
return floats, nil
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) Int
func (cmd *Cmd) Int() (int, error) {
if cmd.err != nil {
return 0, cmd.err
}
switch val := cmd.val.(type) {
case int64:
return int(val), nil
case string:
return strconv.Atoi(val)
default:
err := fmt.Errorf("redis: unexpected type=%T for Int", val)
return 0, err
}
}
Cognitive complexity: 6
, Cyclomatic complexity: 5
func (*Cmd) Int64
func (cmd *Cmd) Int64() (int64, error) {
if cmd.err != nil {
return 0, cmd.err
}
return toInt64(cmd.val)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*Cmd) Int64Slice
func (cmd *Cmd) Int64Slice() ([]int64, error) {
slice, err := cmd.Slice()
if err != nil {
return nil, err
}
nums := make([]int64, len(slice))
for i, iface := range slice {
val, err := toInt64(iface)
if err != nil {
return nil, err
}
nums[i] = val
}
return nums, nil
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) Result
func (cmd *Cmd) Result() (interface{}, error) {
return cmd.val, cmd.err
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Cmd) SetVal
func (cmd *Cmd) SetVal(val interface{}) {
cmd.val = val
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Cmd) Slice
func (cmd *Cmd) Slice() ([]interface{}, error) {
if cmd.err != nil {
return nil, cmd.err
}
switch val := cmd.val.(type) {
case []interface{}:
return val, nil
default:
return nil, fmt.Errorf("redis: unexpected type=%T for Slice", val)
}
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) String
func (cmd *Cmd) String() string {
return cmdString(cmd, cmd.val)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*Cmd) StringSlice
func (cmd *Cmd) StringSlice() ([]string, error) {
slice, err := cmd.Slice()
if err != nil {
return nil, err
}
ss := make([]string, len(slice))
for i, iface := range slice {
val, err := toString(iface)
if err != nil {
return nil, err
}
ss[i] = val
}
return ss, nil
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) Text
func (cmd *Cmd) Text() (string, error) {
if cmd.err != nil {
return "", cmd.err
}
return toString(cmd.val)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*Cmd) Uint64
func (cmd *Cmd) Uint64() (uint64, error) {
if cmd.err != nil {
return 0, cmd.err
}
return toUint64(cmd.val)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*Cmd) Uint64Slice
func (cmd *Cmd) Uint64Slice() ([]uint64, error) {
slice, err := cmd.Slice()
if err != nil {
return nil, err
}
nums := make([]uint64, len(slice))
for i, iface := range slice {
val, err := toUint64(iface)
if err != nil {
return nil, err
}
nums[i] = val
}
return nums, nil
}
Cognitive complexity: 7
, Cyclomatic complexity: 4
func (*Cmd) Val
func (cmd *Cmd) Val() interface{} {
return cmd.val
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*FunctionListCmd) First
func (cmd *FunctionListCmd) First() (*Library, error) {
if cmd.err != nil {
return nil, cmd.err
}
if len(cmd.val) > 0 {
return &cmd.val[0], nil
}
return nil, Nil
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func (*FunctionStats) AllRunningScripts
AllRunningScripts returns all scripts currently running in a Redis Enterprise clustered database. Only available on Redis Enterprise
func (fs *FunctionStats) AllRunningScripts() []RunningScript {
return fs.allrs
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*FunctionStats) Running
func (fs *FunctionStats) Running() bool {
return fs.isRunning
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*FunctionStats) RunningScript
func (fs *FunctionStats) RunningScript() (RunningScript, bool) {
return fs.rs, fs.isRunning
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*InfoCmd) Item
func (cmd *InfoCmd) Item(section, key string) string {
if cmd.val == nil {
return ""
} else if cmd.val[section] == nil {
return ""
} else {
return cmd.val[section][key]
}
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (*JSONCmd) Expanded
func (cmd *JSONCmd) Expanded() (interface{}, error) {
if len(cmd.val) != 0 && cmd.expanded == nil {
err := json.Unmarshal([]byte(cmd.val), &cmd.expanded)
if err != nil {
return nil, err
}
}
return cmd.expanded, nil
}
Cognitive complexity: 5
, Cyclomatic complexity: 4
func (*MonitorCmd) Start
func (cmd *MonitorCmd) Start() {
cmd.mu.Lock()
defer cmd.mu.Unlock()
cmd.status = monitorStatusStart
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*MonitorCmd) Stop
func (cmd *MonitorCmd) Stop() {
cmd.mu.Lock()
defer cmd.mu.Unlock()
cmd.status = monitorStatusStop
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*Pipeline) Discard
Discard resets the pipeline and discards queued commands.
func (c *Pipeline) Discard() {
c.cmds = c.cmds[:0]
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*Pipeline) Exec
Exec executes all previously queued commands using one client-server roundtrip.
Exec always returns list of commands and error of the first failed command if any.
func (c *Pipeline) Exec(ctx context.Context) ([]Cmder, error) {
if len(c.cmds) == 0 {
return nil, nil
}
cmds := c.cmds
c.cmds = nil
return cmds, c.exec(ctx, cmds)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*PubSub) Channel
Channel returns a Go channel for concurrently receiving messages. The channel is closed together with the PubSub. If the Go channel is blocked full for 1 minute the message is dropped. Receive* APIs can not be used after channel is created.
go-redis periodically sends ping messages to test connection health and re-subscribes if ping can not received for 1 minute.
func (c *PubSub) Channel(opts ...ChannelOption) <-chan *Message {
c.chOnce.Do(func() {
c.msgCh = newChannel(c, opts...)
c.msgCh.initMsgChan()
})
if c.msgCh == nil {
err := fmt.Errorf("redis: Channel can't be called after ChannelWithSubscriptions")
panic(err)
}
return c.msgCh.msgCh
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (*PubSub) ChannelSize
ChannelSize is like Channel, but creates a Go channel with specified buffer size.
Deprecated: use Channel(WithChannelSize(size)), remove in v9.
func (c *PubSub) ChannelSize(size int) <-chan *Message {
return c.Channel(WithChannelSize(size))
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*PubSub) ChannelWithSubscriptions
ChannelWithSubscriptions is like Channel, but message type can be either *Subscription or *Message. Subscription messages can be used to detect reconnections.
ChannelWithSubscriptions can not be used together with Channel or ChannelSize.
func (c *PubSub) ChannelWithSubscriptions(opts ...ChannelOption) <-chan interface{} {
c.chOnce.Do(func() {
c.allCh = newChannel(c, opts...)
c.allCh.initAllChan()
})
if c.allCh == nil {
err := fmt.Errorf("redis: ChannelWithSubscriptions can't be called after Channel")
panic(err)
}
return c.allCh.allCh
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (*PubSub) PUnsubscribe
PUnsubscribe the client from the given patterns, or from all of them if none is given.
func (c *PubSub) PUnsubscribe(ctx context.Context, patterns ...string) error {
c.mu.Lock()
defer c.mu.Unlock()
if len(patterns) > 0 {
for _, pattern := range patterns {
delete(c.patterns, pattern)
}
} else {
// Unsubscribe from all patterns.
for pattern := range c.patterns {
delete(c.patterns, pattern)
}
}
err := c.subscribe(ctx, "punsubscribe", patterns...)
return err
}
Cognitive complexity: 10
, Cyclomatic complexity: 4
func (*PubSub) Receive
Receive returns a message as a Subscription, Message, Pong or error. See PubSub example for details. This is low-level API and in most cases Channel should be used instead.
func (c *PubSub) Receive(ctx context.Context) (interface{}, error) {
return c.ReceiveTimeout(ctx, 0)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*PubSub) ReceiveMessage
ReceiveMessage returns a Message or error ignoring Subscription and Pong messages. This is low-level API and in most cases Channel should be used instead.
func (c *PubSub) ReceiveMessage(ctx context.Context) (*Message, error) {
for {
msg, err := c.Receive(ctx)
if err != nil {
return nil, err
}
switch msg := msg.(type) {
case *Subscription:
// Ignore.
case *Pong:
// Ignore.
case *Message:
return msg, nil
default:
err := fmt.Errorf("redis: unknown message: %T", msg)
return nil, err
}
}
}
Cognitive complexity: 9
, Cyclomatic complexity: 7
func (*PubSub) ReceiveTimeout
ReceiveTimeout acts like Receive but returns an error if message is not received in time. This is low-level API and in most cases Channel should be used instead.
func (c *PubSub) ReceiveTimeout(ctx context.Context, timeout time.Duration) (interface{}, error) {
if c.cmd == nil {
c.cmd = NewCmd(ctx)
}
// Don't hold the lock to allow subscriptions and pings.
cn, err := c.connWithLock(ctx)
if err != nil {
return nil, err
}
err = cn.WithReader(context.Background(), timeout, func(rd *proto.Reader) error {
return c.cmd.readReply(rd)
})
c.releaseConnWithLock(ctx, cn, err, timeout > 0)
if err != nil {
return nil, err
}
return c.newMessage(c.cmd.Val())
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (*PubSub) SUnsubscribe
SUnsubscribe unsubscribes the client from the given shard channels, or from all of them if none is given.
func (c *PubSub) SUnsubscribe(ctx context.Context, channels ...string) error {
c.mu.Lock()
defer c.mu.Unlock()
if len(channels) > 0 {
for _, channel := range channels {
delete(c.schannels, channel)
}
} else {
// Unsubscribe from all channels.
for channel := range c.schannels {
delete(c.schannels, channel)
}
}
err := c.subscribe(ctx, "sunsubscribe", channels...)
return err
}
Cognitive complexity: 10
, Cyclomatic complexity: 4
func (*PubSub) Unsubscribe
Unsubscribe the client from the given channels, or from all of them if none is given.
func (c *PubSub) Unsubscribe(ctx context.Context, channels ...string) error {
c.mu.Lock()
defer c.mu.Unlock()
if len(channels) > 0 {
for _, channel := range channels {
delete(c.channels, channel)
}
} else {
// Unsubscribe from all channels.
for channel := range c.channels {
delete(c.channels, channel)
}
}
err := c.subscribe(ctx, "unsubscribe", channels...)
return err
}
Cognitive complexity: 10
, Cyclomatic complexity: 4
func (*ScanCmd) Iterator
Iterator creates a new ScanIterator.
func (cmd *ScanCmd) Iterator() *ScanIterator {
return &ScanIterator{
cmd: cmd,
}
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*ScanIterator) Next
Next advances the cursor and returns true if more values can be read.
func (it *ScanIterator) Next(ctx context.Context) bool {
// Instantly return on errors.
if it.cmd.Err() != nil {
return false
}
// Advance cursor, check if we are still within range.
if it.pos < len(it.cmd.page) {
it.pos++
return true
}
for {
// Return if there is no more data to fetch.
if it.cmd.cursor == 0 {
return false
}
// Fetch next page.
switch it.cmd.args[0] {
case "scan", "qscan":
it.cmd.args[1] = it.cmd.cursor
default:
it.cmd.args[2] = it.cmd.cursor
}
err := it.cmd.process(ctx, it.cmd)
if err != nil {
return false
}
it.pos = 1
// Redis can occasionally return empty page.
if len(it.cmd.page) > 0 {
return true
}
}
}
Cognitive complexity: 15
, Cyclomatic complexity: 9
func (*Script) Eval
func (s *Script) Eval(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
return c.Eval(ctx, s.src, keys, args...)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Script) EvalRO
func (s *Script) EvalRO(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
return c.EvalRO(ctx, s.src, keys, args...)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Script) EvalSha
func (s *Script) EvalSha(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
return c.EvalSha(ctx, s.hash, keys, args...)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Script) EvalShaRO
func (s *Script) EvalShaRO(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
return c.EvalShaRO(ctx, s.hash, keys, args...)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Script) Load
func (s *Script) Load(ctx context.Context, c Scripter) *StringCmd {
return c.ScriptLoad(ctx, s.src)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*Script) Run
Run optimistically uses EVALSHA to run the script. If script does not exist it is retried using EVAL.
func (s *Script) Run(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
r := s.EvalSha(ctx, c, keys, args...)
if HasErrorPrefix(r.Err(), "NOSCRIPT") {
return s.Eval(ctx, c, keys, args...)
}
return r
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (*Script) RunRO
RunRO optimistically uses EVALSHA_RO to run the script. If script does not exist it is retried using EVAL_RO.
func (s *Script) RunRO(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
r := s.EvalShaRO(ctx, c, keys, args...)
if HasErrorPrefix(r.Err(), "NOSCRIPT") {
return s.EvalRO(ctx, c, keys, args...)
}
return r
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (*SentinelClient) CkQuorum
CkQuorum checks if the current Sentinel configuration is able to reach the quorum needed to failover a master, and the majority needed to authorize the failover. This command should be used in monitoring systems to check if a Sentinel deployment is ok.
func (c *SentinelClient) CkQuorum(ctx context.Context, name string) *StringCmd {
cmd := NewStringCmd(ctx, "sentinel", "ckquorum", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Failover
Failover forces a failover as if the master was not reachable, and without asking for agreement to other Sentinels.
func (c *SentinelClient) Failover(ctx context.Context, name string) *StatusCmd {
cmd := NewStatusCmd(ctx, "sentinel", "failover", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) FlushConfig
FlushConfig forces Sentinel to rewrite its configuration on disk, including the current Sentinel state.
func (c *SentinelClient) FlushConfig(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "sentinel", "flushconfig")
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) GetMasterAddrByName
func (c *SentinelClient) GetMasterAddrByName(ctx context.Context, name string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "sentinel", "get-master-addr-by-name", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Master
Master shows the state and info of the specified master.
func (c *SentinelClient) Master(ctx context.Context, name string) *MapStringStringCmd {
cmd := NewMapStringStringCmd(ctx, "sentinel", "master", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Masters
Masters shows a list of monitored masters and their state.
func (c *SentinelClient) Masters(ctx context.Context) *SliceCmd {
cmd := NewSliceCmd(ctx, "sentinel", "masters")
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Remove
Remove is used in order to remove the specified master: the master will no longer be monitored, and will totally be removed from the internal state of the Sentinel.
func (c *SentinelClient) Remove(ctx context.Context, name string) *StringCmd {
cmd := NewStringCmd(ctx, "sentinel", "remove", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Replicas
Replicas shows a list of replicas for the specified master and their state.
func (c *SentinelClient) Replicas(ctx context.Context, name string) *MapStringStringSliceCmd {
cmd := NewMapStringStringSliceCmd(ctx, "sentinel", "replicas", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Reset
Reset resets all the masters with matching name. The pattern argument is a glob-style pattern. The reset process clears any previous state in a master (including a failover in progress), and removes every replica and sentinel already discovered and associated with the master.
func (c *SentinelClient) Reset(ctx context.Context, pattern string) *IntCmd {
cmd := NewIntCmd(ctx, "sentinel", "reset", pattern)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Sentinels
func (c *SentinelClient) Sentinels(ctx context.Context, name string) *MapStringStringSliceCmd {
cmd := NewMapStringStringSliceCmd(ctx, "sentinel", "sentinels", name)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SentinelClient) Set
Set is used in order to change configuration parameters of a specific master.
func (c *SentinelClient) Set(ctx context.Context, name, option, value string) *StringCmd {
cmd := NewStringCmd(ctx, "sentinel", "set", name, option, value)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*SliceCmd) Scan
Scan scans the results from the map into a destination struct. The map keys
are matched in the Redis struct fields by the redis:"field"
tag.
func (cmd *SliceCmd) Scan(dst interface{}) error {
if cmd.err != nil {
return cmd.err
}
// Pass the list of keys and values.
// Skip the first two args for: HMGET key
var args []interface{}
if cmd.args[0] == "hmget" {
args = cmd.args[2:]
} else {
// Otherwise, it's: MGET field field ...
args = cmd.args[1:]
}
return hscan.Scan(dst, args, cmd.val)
}
Cognitive complexity: 8
, Cyclomatic complexity: 3
func (*StatusCmd) Bytes
func (cmd *StatusCmd) Bytes() ([]byte, error) {
return util.StringToBytes(cmd.val), cmd.err
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*StringCmd) Time
func (cmd *StringCmd) Time() (time.Time, error) {
if cmd.err != nil {
return time.Time{}, cmd.err
}
return time.Parse(time.RFC3339Nano, cmd.Val())
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (*StringSliceCmd) ScanSlice
func (cmd *StringSliceCmd) ScanSlice(container interface{}) error {
return proto.ScanSlice(cmd.Val(), container)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*Tx) Unwatch
Unwatch flushes all the previously watched keys for a transaction.
func (c *Tx) Unwatch(ctx context.Context, keys ...string) *StatusCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "unwatch"
for i, key := range keys {
args[1+i] = key
}
cmd := NewStatusCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (*UniversalOptions) Cluster
Cluster returns cluster options created from the universal options.
func (o *UniversalOptions) Cluster() *ClusterOptions {
if len(o.Addrs) == 0 {
o.Addrs = []string{"127.0.0.1:6379"}
}
return &ClusterOptions{
Addrs: o.Addrs,
ClientName: o.ClientName,
Dialer: o.Dialer,
OnConnect: o.OnConnect,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
MaxRedirects: o.MaxRedirects,
ReadOnly: o.ReadOnly,
RouteByLatency: o.RouteByLatency,
RouteRandomly: o.RouteRandomly,
MaxRetries: o.MaxRetries,
MinRetryBackoff: o.MinRetryBackoff,
MaxRetryBackoff: o.MaxRetryBackoff,
DialTimeout: o.DialTimeout,
ReadTimeout: o.ReadTimeout,
WriteTimeout: o.WriteTimeout,
ContextTimeoutEnabled: o.ContextTimeoutEnabled,
PoolFIFO: o.PoolFIFO,
PoolSize: o.PoolSize,
PoolTimeout: o.PoolTimeout,
MinIdleConns: o.MinIdleConns,
MaxIdleConns: o.MaxIdleConns,
MaxActiveConns: o.MaxActiveConns,
ConnMaxIdleTime: o.ConnMaxIdleTime,
ConnMaxLifetime: o.ConnMaxLifetime,
TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (*UniversalOptions) Simple
Simple returns basic options created from the universal options.
func (o *UniversalOptions) Simple() *Options {
addr := "127.0.0.1:6379"
if len(o.Addrs) > 0 {
addr = o.Addrs[0]
}
return &Options{
Addr: addr,
ClientName: o.ClientName,
Dialer: o.Dialer,
OnConnect: o.OnConnect,
DB: o.DB,
Protocol: o.Protocol,
Username: o.Username,
Password: o.Password,
MaxRetries: o.MaxRetries,
MinRetryBackoff: o.MinRetryBackoff,
MaxRetryBackoff: o.MaxRetryBackoff,
DialTimeout: o.DialTimeout,
ReadTimeout: o.ReadTimeout,
WriteTimeout: o.WriteTimeout,
ContextTimeoutEnabled: o.ContextTimeoutEnabled,
PoolFIFO: o.PoolFIFO,
PoolSize: o.PoolSize,
PoolTimeout: o.PoolTimeout,
MinIdleConns: o.MinIdleConns,
MaxIdleConns: o.MaxIdleConns,
MaxActiveConns: o.MaxActiveConns,
ConnMaxIdleTime: o.ConnMaxIdleTime,
ConnMaxLifetime: o.ConnMaxLifetime,
TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3: o.UnstableResp3,
}
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (*baseCmd) Args
func (cmd *baseCmd) Args() []interface{} {
return cmd.args
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (*baseCmd) Err
func (cmd *baseCmd) Err() error {
return cmd.err
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*baseCmd) FullName
func (cmd *baseCmd) FullName() string {
switch name := cmd.Name(); name {
case "cluster", "command":
if len(cmd.args) == 1 {
return name
}
if s2, ok := cmd.args[1].(string); ok {
return name + " " + s2
}
return name
default:
return name
}
}
Cognitive complexity: 7
, Cyclomatic complexity: 5
func (*baseCmd) Name
func (cmd *baseCmd) Name() string {
if len(cmd.args) == 0 {
return ""
}
// Cmd name must be lower cased.
return internal.ToLower(cmd.stringArg(0))
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*baseCmd) SetErr
func (cmd *baseCmd) SetErr(e error) {
cmd.err = e
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*baseCmd) SetFirstKeyPos
func (cmd *baseCmd) SetFirstKeyPos(keyPos int8) {
cmd.keyPos = keyPos
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNode) Close
func (n *clusterNode) Close() error {
return n.Client.Close()
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNode) Failing
func (n *clusterNode) Failing() bool {
const timeout = 15 // 15 seconds
failing := atomic.LoadUint32(&n.failing)
if failing == 0 {
return false
}
if time.Now().Unix()-int64(failing) < timeout {
return true
}
atomic.StoreUint32(&n.failing, 0)
return false
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func (*clusterNode) Generation
func (n *clusterNode) Generation() uint32 {
return atomic.LoadUint32(&n.generation)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNode) LastLatencyMeasurement
func (n *clusterNode) LastLatencyMeasurement() int64 {
return atomic.LoadInt64(&n.lastLatencyMeasurement)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNode) Latency
func (n *clusterNode) Latency() time.Duration {
latency := atomic.LoadUint32(&n.latency)
return time.Duration(latency) * time.Microsecond
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNode) MarkAsFailing
func (n *clusterNode) MarkAsFailing() {
atomic.StoreUint32(&n.failing, uint32(time.Now().Unix()))
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNode) SetGeneration
func (n *clusterNode) SetGeneration(gen uint32) {
for {
v := atomic.LoadUint32(&n.generation)
if gen < v || atomic.CompareAndSwapUint32(&n.generation, v, gen) {
break
}
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 4
func (*clusterNode) SetLastLatencyMeasurement
func (n *clusterNode) SetLastLatencyMeasurement(t time.Time) {
for {
v := atomic.LoadInt64(&n.lastLatencyMeasurement)
if t.UnixNano() < v || atomic.CompareAndSwapInt64(&n.lastLatencyMeasurement, v, t.UnixNano()) {
break
}
}
}
Cognitive complexity: 4
, Cyclomatic complexity: 4
func (*clusterNodes) Addrs
func (c *clusterNodes) Addrs() ([]string, error) {
var addrs []string
c.mu.RLock()
closed := c.closed //nolint:ifshort
if !closed {
if len(c.activeAddrs) > 0 {
addrs = c.activeAddrs
} else {
addrs = c.addrs
}
}
c.mu.RUnlock()
if closed {
return nil, pool.ErrClosed
}
if len(addrs) == 0 {
return nil, errClusterNoNodes
}
return addrs, nil
}
Cognitive complexity: 10
, Cyclomatic complexity: 5
func (*clusterNodes) All
func (c *clusterNodes) All() ([]*clusterNode, error) {
c.mu.RLock()
defer c.mu.RUnlock()
if c.closed {
return nil, pool.ErrClosed
}
cp := make([]*clusterNode, 0, len(c.nodes))
for _, node := range c.nodes {
cp = append(cp, node)
}
return cp, nil
}
Cognitive complexity: 5
, Cyclomatic complexity: 3
func (*clusterNodes) GC
GC removes unused nodes.
func (c *clusterNodes) GC(generation uint32) {
//nolint:prealloc
var collected []*clusterNode
c.mu.Lock()
c.activeAddrs = c.activeAddrs[:0]
now := time.Now()
for addr, node := range c.nodes {
if node.Generation() >= generation {
c.activeAddrs = append(c.activeAddrs, addr)
if c.opt.RouteByLatency && node.LastLatencyMeasurement() < now.Add(-minLatencyMeasurementInterval).UnixNano() {
go node.updateLatency()
}
continue
}
delete(c.nodes, addr)
collected = append(collected, node)
}
c.mu.Unlock()
for _, node := range collected {
_ = node.Client.Close()
}
}
Cognitive complexity: 10
, Cyclomatic complexity: 6
func (*clusterNodes) GetOrCreate
func (c *clusterNodes) GetOrCreate(addr string) (*clusterNode, error) {
node, err := c.get(addr)
if err != nil {
return nil, err
}
if node != nil {
return node, nil
}
c.mu.Lock()
defer c.mu.Unlock()
if c.closed {
return nil, pool.ErrClosed
}
node, ok := c.nodes[addr]
if ok {
return node, nil
}
node = newClusterNode(c.opt, addr)
for _, fn := range c.onNewNode {
fn(node.Client)
}
c.addrs = appendIfNotExists(c.addrs, addr)
c.nodes[addr] = node
return node, nil
}
Cognitive complexity: 11
, Cyclomatic complexity: 6
func (*clusterNodes) NextGeneration
func (c *clusterNodes) NextGeneration() uint32 {
return atomic.AddUint32(&c._generation, 1)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNodes) OnNewNode
func (c *clusterNodes) OnNewNode(fn func(rdb *Client)) {
c.mu.Lock()
c.onNewNode = append(c.onNewNode, fn)
c.mu.Unlock()
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*clusterNodes) Random
func (c *clusterNodes) Random() (*clusterNode, error) {
addrs, err := c.Addrs()
if err != nil {
return nil, err
}
n := rand.Intn(len(addrs))
return c.GetOrCreate(addrs[n])
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*clusterStateHolder) LazyReload
func (c *clusterStateHolder) LazyReload() {
if !atomic.CompareAndSwapUint32(&c.reloading, 0, 1) {
return
}
go func() {
defer atomic.StoreUint32(&c.reloading, 0)
_, err := c.Reload(context.Background())
if err != nil {
return
}
time.Sleep(200 * time.Millisecond)
}()
}
Cognitive complexity: 5
, Cyclomatic complexity: 3
func (*clusterStateHolder) Reload
func (c *clusterStateHolder) Reload(ctx context.Context) (*clusterState, error) {
state, err := c.load(ctx)
if err != nil {
return nil, err
}
c.state.Store(state)
return state, nil
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*clusterStateHolder) ReloadOrGet
func (c *clusterStateHolder) ReloadOrGet(ctx context.Context) (*clusterState, error) {
state, err := c.Reload(ctx)
if err == nil {
return state, nil
}
return c.Get(ctx)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*cmdsInfoCache) Get
func (c *cmdsInfoCache) Get(ctx context.Context) (map[string]*CommandInfo, error) {
err := c.once.Do(func() error {
cmds, err := c.fn(ctx)
if err != nil {
return err
}
// Extensions have cmd names in upper case. Convert them to lower case.
for k, v := range cmds {
lower := internal.ToLower(k)
if lower != k {
cmds[lower] = v
}
}
c.cmds = cmds
return nil
})
return c.cmds, err
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (*cmdsMap) Add
func (m *cmdsMap) Add(node *clusterNode, cmds ...Cmder) {
m.mu.Lock()
m.m[node] = append(m.m[node], cmds...)
m.mu.Unlock()
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*hooksMixin) AddHook
AddHook is to add a hook to the queue. Hook is a function executed during network connection, command execution, and pipeline, it is a first-in-first-out stack queue (FIFO). You need to execute the next hook in each hook, unless you want to terminate the execution of the command. For example, you added hook-1, hook-2:
client.AddHook(hook-1, hook-2)
hook-1:
func (Hook1) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return func(ctx context.Context, cmd Cmder) error {
print("hook-1 start")
next(ctx, cmd)
print("hook-1 end")
return nil
}
}
hook-2:
func (Hook2) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return func(ctx context.Context, cmd redis.Cmder) error {
print("hook-2 start")
next(ctx, cmd)
print("hook-2 end")
return nil
}
}
The execution sequence is:
hook-1 start -> hook-2 start -> exec redis cmd -> hook-2 end -> hook-1 end
Please note: "next(ctx, cmd)" is very important, it will call the next hook, if "next(ctx, cmd)" is not executed, the redis command will not be executed.
func (hs *hooksMixin) AddHook(hook Hook) {
hs.slice = append(hs.slice, hook)
hs.chain()
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ringShard) IsDown
func (shard *ringShard) IsDown() bool {
const threshold = 3
return atomic.LoadInt32(&shard.down) >= threshold
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ringShard) IsUp
func (shard *ringShard) IsUp() bool {
return !shard.IsDown()
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (*ringShard) Vote
Vote votes to set shard state and returns true if state was changed.
func (shard *ringShard) Vote(up bool) bool {
if up {
changed := shard.IsDown()
atomic.StoreInt32(&shard.down, 0)
return changed
}
if shard.IsDown() {
return false
}
atomic.AddInt32(&shard.down, 1)
return shard.IsDown()
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func (*ringSharding) GetByKey
func (c *ringSharding) GetByKey(key string) (*ringShard, error) {
key = hashtag.Key(key)
c.mu.RLock()
defer c.mu.RUnlock()
if c.closed {
return nil, pool.ErrClosed
}
if c.numShard == 0 {
return nil, errRingShardsDown
}
shardName := c.hash.Get(key)
if shardName == "" {
return nil, errRingShardsDown
}
return c.shards.m[shardName], nil
}
Cognitive complexity: 6
, Cyclomatic complexity: 4
func (*ringSharding) GetByName
func (c *ringSharding) GetByName(shardName string) (*ringShard, error) {
if shardName == "" {
return c.Random()
}
c.mu.RLock()
defer c.mu.RUnlock()
return c.shards.m[shardName], nil
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ringSharding) Hash
func (c *ringSharding) Hash(key string) string {
key = hashtag.Key(key)
var hash string
c.mu.RLock()
defer c.mu.RUnlock()
if c.numShard > 0 {
hash = c.hash.Get(key)
}
return hash
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ringSharding) Heartbeat
Heartbeat monitors state of each shard in the ring.
func (c *ringSharding) Heartbeat(ctx context.Context, frequency time.Duration) {
ticker := time.NewTicker(frequency)
defer ticker.Stop()
for {
select {
case <-ticker.C:
var rebalance bool
for _, shard := range c.List() {
err := shard.Client.Ping(ctx).Err()
isUp := err == nil || err == pool.ErrPoolTimeout
if shard.Vote(isUp) {
internal.Logger.Printf(ctx, "ring shard state changed: %s", shard)
rebalance = true
}
}
if rebalance {
c.mu.Lock()
c.rebalanceLocked()
c.mu.Unlock()
}
case <-ctx.Done():
return
}
}
}
Cognitive complexity: 12
, Cyclomatic complexity: 8
func (*ringSharding) List
func (c *ringSharding) List() []*ringShard {
var list []*ringShard
c.mu.RLock()
if !c.closed {
list = c.shards.list
}
c.mu.RUnlock()
return list
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (*ringSharding) SetAddrs
SetAddrs replaces the shards in use, such that you can increase and decrease number of shards, that you use. It will reuse shards that existed before and close the ones that will not be used anymore.
func (c *ringSharding) SetAddrs(addrs map[string]string) {
c.setAddrsMu.Lock()
defer c.setAddrsMu.Unlock()
cleanup := func(shards map[string]*ringShard) {
for addr, shard := range shards {
if err := shard.Client.Close(); err != nil {
internal.Logger.Printf(context.Background(), "shard.Close %s failed: %s", addr, err)
}
}
}
c.mu.RLock()
if c.closed {
c.mu.RUnlock()
return
}
existing := c.shards
c.mu.RUnlock()
shards, created, unused := c.newRingShards(addrs, existing)
c.mu.Lock()
if c.closed {
cleanup(created)
c.mu.Unlock()
return
}
c.shards = shards
c.rebalanceLocked()
c.mu.Unlock()
cleanup(unused)
}
Cognitive complexity: 10
, Cyclomatic complexity: 5
func (*sentinelFailover) MasterAddr
func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) {
c.mu.RLock()
sentinel := c.sentinel
c.mu.RUnlock()
if sentinel != nil {
addr, err := c.getMasterAddr(ctx, sentinel)
if err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return "", err
}
// Continue on other errors
internal.Logger.Printf(ctx, "sentinel: GetMasterAddrByName name=%q failed: %s",
c.opt.MasterName, err)
} else {
return addr, nil
}
}
c.mu.Lock()
defer c.mu.Unlock()
if c.sentinel != nil {
addr, err := c.getMasterAddr(ctx, c.sentinel)
if err != nil {
_ = c.closeSentinel()
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return "", err
}
// Continue on other errors
internal.Logger.Printf(ctx, "sentinel: GetMasterAddrByName name=%q failed: %s",
c.opt.MasterName, err)
} else {
return addr, nil
}
}
for i, sentinelAddr := range c.sentinelAddrs {
sentinel := NewSentinelClient(c.opt.sentinelOptions(sentinelAddr))
masterAddr, err := sentinel.GetMasterAddrByName(ctx, c.opt.MasterName).Result()
if err != nil {
_ = sentinel.Close()
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return "", err
}
internal.Logger.Printf(ctx, "sentinel: GetMasterAddrByName master=%q failed: %s",
c.opt.MasterName, err)
continue
}
// Push working sentinel to the top.
c.sentinelAddrs[0], c.sentinelAddrs[i] = c.sentinelAddrs[i], c.sentinelAddrs[0]
c.setSentinel(ctx, sentinel)
addr := net.JoinHostPort(masterAddr[0], masterAddr[1])
return addr, nil
}
return "", errors.New("redis: all sentinels specified in configuration are unreachable")
}
Cognitive complexity: 23
, Cyclomatic complexity: 13
func (*sentinelFailover) RandomReplicaAddr
func (c *sentinelFailover) RandomReplicaAddr(ctx context.Context) (string, error) {
if c.opt == nil {
return "", errors.New("opt is nil")
}
addresses, err := c.replicaAddrs(ctx, false)
if err != nil {
return "", err
}
if len(addresses) == 0 && c.opt.UseDisconnectedReplicas {
addresses, err = c.replicaAddrs(ctx, true)
if err != nil {
return "", err
}
}
if len(addresses) == 0 {
return c.MasterAddr(ctx)
}
return addresses[rand.Intn(len(addresses))], nil
}
Cognitive complexity: 10
, Cyclomatic complexity: 7
func (LibraryInfo) Validate
Validate checks if only one field in the struct is non-nil.
func (info LibraryInfo) Validate() error {
if info.LibName != nil && info.LibVer != nil {
return errors.New("both LibName and LibVer cannot be set at the same time")
}
if info.LibName == nil && info.LibVer == nil {
return errors.New("at least one of LibName and LibVer should be set")
}
return nil
}
Cognitive complexity: 4
, Cyclomatic complexity: 5
func (clusterSlotSlice) Len
func (p clusterSlotSlice) Len() int {
return len(p)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (clusterSlotSlice) Less
func (p clusterSlotSlice) Less(i, j int) bool {
return p[i].start < p[j].start
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (clusterSlotSlice) Swap
func (p clusterSlotSlice) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ACLDryRun
func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd {
args := make([]interface{}, 0, 3+len(command))
args = append(args, "acl", "dryrun", username)
args = append(args, command...)
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) ACLLog
func (c cmdable) ACLLog(ctx context.Context, count int64) *ACLLogCmd {
args := make([]interface{}, 0, 3)
args = append(args, "acl", "log")
if count > 0 {
args = append(args, count)
}
cmd := NewACLLogCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (cmdable) ACLLogReset
func (c cmdable) ACLLogReset(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "acl", "log", "reset")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Append
func (c cmdable) Append(ctx context.Context, key, value string) *IntCmd {
cmd := NewIntCmd(ctx, "append", key, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BFAdd
BFAdd adds an item to a Bloom filter. For more information - https://redis.io/commands/bf.add/
func (c cmdable) BFAdd(ctx context.Context, key string, element interface{}) *BoolCmd {
args := []interface{}{"BF.ADD", key, element}
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) BFCard
BFCard returns the cardinality of a Bloom filter - number of items that were added to a Bloom filter and detected as unique (items that caused at least one bit to be set in at least one sub-filter). For more information - https://redis.io/commands/bf.card/
func (c cmdable) BFCard(ctx context.Context, key string) *IntCmd {
args := []interface{}{"BF.CARD", key}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BFExists
BFExists determines whether a given item was added to a Bloom filter. For more information - https://redis.io/commands/bf.exists/
func (c cmdable) BFExists(ctx context.Context, key string, element interface{}) *BoolCmd {
args := []interface{}{"BF.EXISTS", key, element}
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) BFInfo
Returns information about a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfo(ctx context.Context, key string) *BFInfoCmd {
args := []interface{}{"BF.INFO", key}
cmd := NewBFInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BFInfoArg
BFInfoArg returns information about a specific option of a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfoArg(ctx context.Context, key, option string) *BFInfoCmd {
args := []interface{}{"BF.INFO", key, option}
cmd := NewBFInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BFInfoCapacity
BFInfoCapacity returns information about the capacity of a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfoCapacity(ctx context.Context, key string) *BFInfoCmd {
return c.BFInfoArg(ctx, key, "CAPACITY")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BFInfoExpansion
BFInfoExpansion returns information about the expansion rate of a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfoExpansion(ctx context.Context, key string) *BFInfoCmd {
return c.BFInfoArg(ctx, key, "EXPANSION")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BFInfoFilters
BFInfoFilters returns information about the filters of a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfoFilters(ctx context.Context, key string) *BFInfoCmd {
return c.BFInfoArg(ctx, key, "FILTERS")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BFInfoItems
BFInfoItems returns information about the items of a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfoItems(ctx context.Context, key string) *BFInfoCmd {
return c.BFInfoArg(ctx, key, "ITEMS")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BFInfoSize
BFInfoSize returns information about the size of a Bloom filter. For more information - https://redis.io/commands/bf.info/
func (c cmdable) BFInfoSize(ctx context.Context, key string) *BFInfoCmd {
return c.BFInfoArg(ctx, key, "SIZE")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BFInsert
BFInsert inserts elements into a Bloom filter. This function also allows for specifying additional options such as: capacity, error rate, expansion rate, and non-scaling behavior. For more information - https://redis.io/commands/bf.insert/
func (c cmdable) BFInsert(ctx context.Context, key string, options *BFInsertOptions, elements ...interface{}) *BoolSliceCmd {
args := []interface{}{"BF.INSERT", key}
if options != nil {
if options.Capacity != 0 {
args = append(args, "CAPACITY", options.Capacity)
}
if options.Error != 0 {
args = append(args, "ERROR", options.Error)
}
if options.Expansion != 0 {
args = append(args, "EXPANSION", options.Expansion)
}
if options.NoCreate {
args = append(args, "NOCREATE")
}
if options.NonScaling {
args = append(args, "NONSCALING")
}
}
args = append(args, "ITEMS")
args = append(args, elements...)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 15
, Cyclomatic complexity: 7
func (cmdable) BFLoadChunk
BFLoadChunk restores a Bloom filter previously saved using BF.SCANDUMP. For more information - https://redis.io/commands/bf.loadchunk/
func (c cmdable) BFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd {
args := []interface{}{"BF.LOADCHUNK", key, iterator, data}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) BFMAdd
BFMAdd adds multiple elements to a Bloom filter. Returns an array of booleans indicating whether each element was added to the filter or not. For more information - https://redis.io/commands/bf.madd/
func (c cmdable) BFMAdd(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd {
args := []interface{}{"BF.MADD", key}
args = append(args, elements...)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) BFMExists
BFMExists check if multiple elements exist in a Bloom filter. Returns an array of booleans indicating whether each element exists in the filter or not. For more information - https://redis.io/commands/bf.mexists/
func (c cmdable) BFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd {
args := []interface{}{"BF.MEXISTS", key}
args = append(args, elements...)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) BFReserve
BFReserve creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound error_rate. For more information - https://redis.io/commands/bf.reserve/
func (c cmdable) BFReserve(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd {
args := []interface{}{"BF.RESERVE", key, errorRate, capacity}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BFReserveExpansion
BFReserveExpansion creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound error_rate. This function also allows for specifying an expansion rate for the filter. For more information - https://redis.io/commands/bf.reserve/
func (c cmdable) BFReserveExpansion(ctx context.Context, key string, errorRate float64, capacity, expansion int64) *StatusCmd {
args := []interface{}{"BF.RESERVE", key, errorRate, capacity, "EXPANSION", expansion}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BFReserveNonScaling
BFReserveNonScaling creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound error_rate. This function also allows for specifying that the filter should not scale. For more information - https://redis.io/commands/bf.reserve/
func (c cmdable) BFReserveNonScaling(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd {
args := []interface{}{"BF.RESERVE", key, errorRate, capacity, "NONSCALING"}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BFReserveWithArgs
BFReserveWithArgs creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound error_rate. This function also allows for specifying additional options such as expansion rate and non-scaling behavior. For more information - https://redis.io/commands/bf.reserve/
func (c cmdable) BFReserveWithArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd {
args := []interface{}{"BF.RESERVE", key}
if options != nil {
args = append(args, options.Error, options.Capacity)
if options.Expansion != 0 {
args = append(args, "EXPANSION", options.Expansion)
}
if options.NonScaling {
args = append(args, "NONSCALING")
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (cmdable) BFScanDump
Begins an incremental save of the Bloom filter. This command is useful for large Bloom filters that cannot fit into the DUMP and RESTORE model. For more information - https://redis.io/commands/bf.scandump/
func (c cmdable) BFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd {
args := []interface{}{"BF.SCANDUMP", key, iterator}
cmd := newScanDumpCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BLMPop
func (c cmdable) BLMPop(ctx context.Context, timeout time.Duration, direction string, count int64, keys ...string) *KeyValuesCmd {
args := make([]interface{}, 3+len(keys), 6+len(keys))
args[0] = "blmpop"
args[1] = formatSec(ctx, timeout)
args[2] = len(keys)
for i, key := range keys {
args[3+i] = key
}
args = append(args, strings.ToLower(direction), "count", count)
cmd := NewKeyValuesCmd(ctx, args...)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) BLMove
func (c cmdable) BLMove(
ctx context.Context, source, destination, srcpos, destpos string, timeout time.Duration,
) *StringCmd {
cmd := NewStringCmd(ctx, "blmove", source, destination, srcpos, destpos, formatSec(ctx, timeout))
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BLPop
func (c cmdable) BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd {
args := make([]interface{}, 1+len(keys)+1)
args[0] = "blpop"
for i, key := range keys {
args[1+i] = key
}
args[len(args)-1] = formatSec(ctx, timeout)
cmd := NewStringSliceCmd(ctx, args...)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) BRPop
func (c cmdable) BRPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd {
args := make([]interface{}, 1+len(keys)+1)
args[0] = "brpop"
for i, key := range keys {
args[1+i] = key
}
args[len(keys)+1] = formatSec(ctx, timeout)
cmd := NewStringSliceCmd(ctx, args...)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) BRPopLPush
func (c cmdable) BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *StringCmd {
cmd := NewStringCmd(
ctx,
"brpoplpush",
source,
destination,
formatSec(ctx, timeout),
)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BZMPop
BZMPop is the blocking variant of ZMPOP. When any of the sorted sets contains elements, this command behaves exactly like ZMPOP. When all sorted sets are empty, Redis will block the connection until another client adds members to one of the keys or until the timeout elapses. A timeout of zero can be used to block indefinitely. example: client.BZMPop(ctx, 0,"max", 1, "set")
func (c cmdable) BZMPop(ctx context.Context, timeout time.Duration, order string, count int64, keys ...string) *ZSliceWithKeyCmd {
args := make([]interface{}, 3+len(keys), 6+len(keys))
args[0] = "bzmpop"
args[1] = formatSec(ctx, timeout)
args[2] = len(keys)
for i, key := range keys {
args[3+i] = key
}
args = append(args, strings.ToLower(order), "count", count)
cmd := NewZSliceWithKeyCmd(ctx, args...)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) BZPopMax
BZPopMax Redis BZPOPMAX key [key ...] timeout
command.
func (c cmdable) BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd {
args := make([]interface{}, 1+len(keys)+1)
args[0] = "bzpopmax"
for i, key := range keys {
args[1+i] = key
}
args[len(args)-1] = formatSec(ctx, timeout)
cmd := NewZWithKeyCmd(ctx, args...)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) BZPopMin
BZPopMin Redis BZPOPMIN key [key ...] timeout
command.
func (c cmdable) BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd {
args := make([]interface{}, 1+len(keys)+1)
args[0] = "bzpopmin"
for i, key := range keys {
args[1+i] = key
}
args[len(args)-1] = formatSec(ctx, timeout)
cmd := NewZWithKeyCmd(ctx, args...)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) BgRewriteAOF
func (c cmdable) BgRewriteAOF(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "bgrewriteaof")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BgSave
func (c cmdable) BgSave(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "bgsave")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BitCount
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
args := make([]any, 2, 5)
args[0] = "bitcount"
args[1] = key
if bitCount != nil {
args = append(args, bitCount.Start, bitCount.End)
if bitCount.Unit != "" {
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
cmd := NewIntCmd(ctx)
cmd.SetErr(errors.New("redis: invalid bitcount index"))
return cmd
}
args = append(args, bitCount.Unit)
}
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 5
func (cmdable) BitField
BitField accepts multiple values:
- BitField("set", "i1", "offset1", "value1","cmd2", "type2", "offset2", "value2")
- BitField([]string{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"})
- BitField([]interface{}{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"})
func (c cmdable) BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "bitfield"
args[1] = key
args = appendArgs(args, values)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) BitFieldRO
BitFieldRO - Read-only variant of the BITFIELD command. It is like the original BITFIELD but only accepts GET subcommand and can safely be used in read-only replicas.
- BitFieldRO(ctx, key, "<Encoding0>", "<Offset0>", "<Encoding1>","<Offset1>")
func (c cmdable) BitFieldRO(ctx context.Context, key string, values ...interface{}) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "BITFIELD_RO"
args[1] = key
if len(values)%2 != 0 {
panic("BitFieldRO: invalid number of arguments, must be even")
}
for i := 0; i < len(values); i += 2 {
args = append(args, "GET", values[i], values[i+1])
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) BitOpAnd
func (c cmdable) BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd {
return c.bitOp(ctx, "and", destKey, keys...)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BitOpNot
func (c cmdable) BitOpNot(ctx context.Context, destKey string, key string) *IntCmd {
return c.bitOp(ctx, "not", destKey, key)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BitOpOr
func (c cmdable) BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd {
return c.bitOp(ctx, "or", destKey, keys...)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BitOpXor
func (c cmdable) BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd {
return c.bitOp(ctx, "xor", destKey, keys...)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) BitPos
BitPos is an API before Redis version 7.0, cmd: bitpos key bit start end
if you need the byte | bit
parameter, please use BitPosSpan
.
func (c cmdable) BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd {
args := make([]interface{}, 3+len(pos))
args[0] = "bitpos"
args[1] = key
args[2] = bit
switch len(pos) {
case 0:
case 1:
args[3] = pos[0]
case 2:
args[3] = pos[0]
args[4] = pos[1]
default:
panic("too many arguments")
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 5
func (cmdable) BitPosSpan
BitPosSpan supports the byte | bit
parameters in redis version 7.0,
the bitpos command defaults to using byte type for the start-end
range,
which means it counts in bytes from start to end. you can set the value
of "span" to determine the type of start-end
.
span = "bit", cmd: bitpos key bit start end bit
span = "byte", cmd: bitpos key bit start end byte
func (c cmdable) BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd {
cmd := NewIntCmd(ctx, "bitpos", key, bit, start, end, span)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) CFAdd
CFAdd adds an element to a Cuckoo filter. Returns true if the element was added to the filter or false if it already exists in the filter. For more information - https://redis.io/commands/cf.add/
func (c cmdable) CFAdd(ctx context.Context, key string, element interface{}) *BoolCmd {
args := []interface{}{"CF.ADD", key, element}
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFAddNX
CFAddNX adds an element to a Cuckoo filter only if it does not already exist in the filter. Returns true if the element was added to the filter or false if it already exists in the filter. For more information - https://redis.io/commands/cf.addnx/
func (c cmdable) CFAddNX(ctx context.Context, key string, element interface{}) *BoolCmd {
args := []interface{}{"CF.ADDNX", key, element}
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFCount
CFCount returns an estimate of the number of times an element may be in a Cuckoo Filter. For more information - https://redis.io/commands/cf.count/
func (c cmdable) CFCount(ctx context.Context, key string, element interface{}) *IntCmd {
args := []interface{}{"CF.COUNT", key, element}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFDel
CFDel deletes an item once from the cuckoo filter. For more information - https://redis.io/commands/cf.del/
func (c cmdable) CFDel(ctx context.Context, key string, element interface{}) *BoolCmd {
args := []interface{}{"CF.DEL", key, element}
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFExists
CFExists determines whether an item may exist in the Cuckoo Filter or not. For more information - https://redis.io/commands/cf.exists/
func (c cmdable) CFExists(ctx context.Context, key string, element interface{}) *BoolCmd {
args := []interface{}{"CF.EXISTS", key, element}
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFInfo
CFInfo returns information about a Cuckoo filter. For more information - https://redis.io/commands/cf.info/
func (c cmdable) CFInfo(ctx context.Context, key string) *CFInfoCmd {
args := []interface{}{"CF.INFO", key}
cmd := NewCFInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CFInsert
CFInsert inserts elements into a Cuckoo filter. This function also allows for specifying additional options such as capacity, error rate, expansion rate, and non-scaling behavior. Returns an array of booleans indicating whether each element was added to the filter or not. For more information - https://redis.io/commands/cf.insert/
func (c cmdable) CFInsert(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *BoolSliceCmd {
args := []interface{}{"CF.INSERT", key}
args = c.getCfInsertWithArgs(args, options, elements...)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFInsertNX
CFInsertNX inserts elements into a Cuckoo filter only if they do not already exist in the filter. This function also allows for specifying additional options such as: capacity, error rate, expansion rate, and non-scaling behavior. Returns an array of integers indicating whether each element was added to the filter or not. For more information - https://redis.io/commands/cf.insertnx/
func (c cmdable) CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd {
args := []interface{}{"CF.INSERTNX", key}
args = c.getCfInsertWithArgs(args, options, elements...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFLoadChunk
CFLoadChunk restores a filter previously saved using SCANDUMP. For more information - https://redis.io/commands/cf.loadchunk/
func (c cmdable) CFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd {
args := []interface{}{"CF.LOADCHUNK", key, iterator, data}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFMExists
CFMExists check if multiple elements exist in a Cuckoo filter. Returns an array of booleans indicating whether each element exists in the filter or not. For more information - https://redis.io/commands/cf.mexists/
func (c cmdable) CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd {
args := []interface{}{"CF.MEXISTS", key}
args = append(args, elements...)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) CFReserve
CFReserve creates an empty Cuckoo filter with the specified capacity. For more information - https://redis.io/commands/cf.reserve/
func (c cmdable) CFReserve(ctx context.Context, key string, capacity int64) *StatusCmd {
args := []interface{}{"CF.RESERVE", key, capacity}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CFReserveBucketSize
CFReserveBucketSize creates an empty Cuckoo filter with the specified capacity and bucket size. For more information - https://redis.io/commands/cf.reserve/
func (c cmdable) CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd {
args := []interface{}{"CF.RESERVE", key, capacity, "BUCKETSIZE", bucketsize}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CFReserveExpansion
CFReserveExpansion creates an empty Cuckoo filter with the specified capacity and expansion rate. For more information - https://redis.io/commands/cf.reserve/
func (c cmdable) CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd {
args := []interface{}{"CF.RESERVE", key, capacity, "EXPANSION", expansion}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CFReserveMaxIterations
CFReserveMaxIterations creates an empty Cuckoo filter with the specified capacity and maximum number of iterations. For more information - https://redis.io/commands/cf.reserve/
func (c cmdable) CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd {
args := []interface{}{"CF.RESERVE", key, capacity, "MAXITERATIONS", maxiterations}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CFReserveWithArgs
CFReserveWithArgs creates an empty Cuckoo filter with the specified options. This function allows for specifying additional options such as bucket size and maximum number of iterations. For more information - https://redis.io/commands/cf.reserve/
func (c cmdable) CFReserveWithArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd {
args := []interface{}{"CF.RESERVE", key, options.Capacity}
if options.BucketSize != 0 {
args = append(args, "BUCKETSIZE", options.BucketSize)
}
if options.MaxIterations != 0 {
args = append(args, "MAXITERATIONS", options.MaxIterations)
}
if options.Expansion != 0 {
args = append(args, "EXPANSION", options.Expansion)
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (cmdable) CFScanDump
CFScanDump begins an incremental save of the cuckoo filter. For more information - https://redis.io/commands/cf.scandump/
func (c cmdable) CFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd {
args := []interface{}{"CF.SCANDUMP", key, iterator}
cmd := newScanDumpCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CMSIncrBy
CMSIncrBy increments the count of one or more items in a Count-Min Sketch filter. Returns an array of integers representing the updated count of each item. For more information - https://redis.io/commands/cms.incrby/
func (c cmdable) CMSIncrBy(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "CMS.INCRBY"
args[1] = key
args = appendArgs(args, elements)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CMSInfo
CMSInfo returns information about a Count-Min Sketch filter. For more information - https://redis.io/commands/cms.info/
func (c cmdable) CMSInfo(ctx context.Context, key string) *CMSInfoCmd {
args := []interface{}{"CMS.INFO", key}
cmd := NewCMSInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CMSInitByDim
CMSInitByDim creates an empty Count-Min Sketch filter with the specified dimensions. For more information - https://redis.io/commands/cms.initbydim/
func (c cmdable) CMSInitByDim(ctx context.Context, key string, width, depth int64) *StatusCmd {
args := []interface{}{"CMS.INITBYDIM", key, width, depth}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CMSInitByProb
CMSInitByProb creates an empty Count-Min Sketch filter with the specified error rate and probability. For more information - https://redis.io/commands/cms.initbyprob/
func (c cmdable) CMSInitByProb(ctx context.Context, key string, errorRate, probability float64) *StatusCmd {
args := []interface{}{"CMS.INITBYPROB", key, errorRate, probability}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CMSMerge
CMSMerge merges multiple Count-Min Sketch filters into a single filter. The destination filter must not exist and will be created with the dimensions of the first source filter. The number of items in each source filter must be equal. Returns OK on success or an error if the filters could not be merged. For more information - https://redis.io/commands/cms.merge/
func (c cmdable) CMSMerge(ctx context.Context, destKey string, sourceKeys ...string) *StatusCmd {
args := []interface{}{"CMS.MERGE", destKey, len(sourceKeys)}
for _, s := range sourceKeys {
args = append(args, s)
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) CMSMergeWithWeight
CMSMergeWithWeight merges multiple Count-Min Sketch filters into a single filter with weights for each source filter. The destination filter must not exist and will be created with the dimensions of the first source filter. The number of items in each source filter must be equal. Returns OK on success or an error if the filters could not be merged. For more information - https://redis.io/commands/cms.merge/
func (c cmdable) CMSMergeWithWeight(ctx context.Context, destKey string, sourceKeys map[string]int64) *StatusCmd {
args := make([]interface{}, 0, 4+(len(sourceKeys)*2+1))
args = append(args, "CMS.MERGE", destKey, len(sourceKeys))
if len(sourceKeys) > 0 {
sk := make([]interface{}, len(sourceKeys))
sw := make([]interface{}, len(sourceKeys))
i := 0
for k, w := range sourceKeys {
sk[i] = k
sw[i] = w
i++
}
args = append(args, sk...)
args = append(args, "WEIGHTS")
args = append(args, sw...)
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 8
, Cyclomatic complexity: 3
func (cmdable) CMSQuery
CMSQuery returns count for item(s). For more information - https://redis.io/commands/cms.query/
func (c cmdable) CMSQuery(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd {
args := []interface{}{"CMS.QUERY", key}
args = append(args, elements...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) ClientGetName
ClientGetName returns the name of the connection.
func (c cmdable) ClientGetName(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "client", "getname")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientID
func (c cmdable) ClientID(ctx context.Context) *IntCmd {
cmd := NewIntCmd(ctx, "client", "id")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientInfo
func (c cmdable) ClientInfo(ctx context.Context) *ClientInfoCmd {
cmd := NewClientInfoCmd(ctx, "client", "info")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientKill
func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd {
cmd := NewStatusCmd(ctx, "client", "kill", ipPort)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientKillByFilter
ClientKillByFilter is new style syntax, while the ClientKill is old
CLIENT KILL <option> [value] ... <option> [value]
func (c cmdable) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "client"
args[1] = "kill"
for i, key := range keys {
args[2+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ClientList
func (c cmdable) ClientList(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "client", "list")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientPause
func (c cmdable) ClientPause(ctx context.Context, dur time.Duration) *BoolCmd {
cmd := NewBoolCmd(ctx, "client", "pause", formatMs(ctx, dur))
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientUnblock
func (c cmdable) ClientUnblock(ctx context.Context, id int64) *IntCmd {
cmd := NewIntCmd(ctx, "client", "unblock", id)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientUnblockWithError
func (c cmdable) ClientUnblockWithError(ctx context.Context, id int64) *IntCmd {
cmd := NewIntCmd(ctx, "client", "unblock", id, "error")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClientUnpause
func (c cmdable) ClientUnpause(ctx context.Context) *BoolCmd {
cmd := NewBoolCmd(ctx, "client", "unpause")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterAddSlots
func (c cmdable) ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd {
args := make([]interface{}, 2+len(slots))
args[0] = "cluster"
args[1] = "addslots"
for i, num := range slots {
args[2+i] = num
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ClusterAddSlotsRange
func (c cmdable) ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd {
size := max - min + 1
slots := make([]int, size)
for i := 0; i < size; i++ {
slots[i] = min + i
}
return c.ClusterAddSlots(ctx, slots...)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (cmdable) ClusterCountFailureReports
func (c cmdable) ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd {
cmd := NewIntCmd(ctx, "cluster", "count-failure-reports", nodeID)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterCountKeysInSlot
func (c cmdable) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd {
cmd := NewIntCmd(ctx, "cluster", "countkeysinslot", slot)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterDelSlots
func (c cmdable) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd {
args := make([]interface{}, 2+len(slots))
args[0] = "cluster"
args[1] = "delslots"
for i, slot := range slots {
args[2+i] = slot
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ClusterDelSlotsRange
func (c cmdable) ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd {
size := max - min + 1
slots := make([]int, size)
for i := 0; i < size; i++ {
slots[i] = min + i
}
return c.ClusterDelSlots(ctx, slots...)
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (cmdable) ClusterFailover
func (c cmdable) ClusterFailover(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "failover")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterForget
func (c cmdable) ClusterForget(ctx context.Context, nodeID string) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "forget", nodeID)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterGetKeysInSlot
func (c cmdable) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", slot, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterInfo
func (c cmdable) ClusterInfo(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "cluster", "info")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterKeySlot
func (c cmdable) ClusterKeySlot(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "cluster", "keyslot", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterLinks
func (c cmdable) ClusterLinks(ctx context.Context) *ClusterLinksCmd {
cmd := NewClusterLinksCmd(ctx, "cluster", "links")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterMeet
func (c cmdable) ClusterMeet(ctx context.Context, host, port string) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "meet", host, port)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterMyShardID
func (c cmdable) ClusterMyShardID(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "cluster", "myshardid")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterNodes
func (c cmdable) ClusterNodes(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "cluster", "nodes")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterReplicate
func (c cmdable) ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "replicate", nodeID)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterResetHard
func (c cmdable) ClusterResetHard(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "reset", "hard")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterResetSoft
func (c cmdable) ClusterResetSoft(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "reset", "soft")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterSaveConfig
func (c cmdable) ClusterSaveConfig(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "cluster", "saveconfig")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterShards
func (c cmdable) ClusterShards(ctx context.Context) *ClusterShardsCmd {
cmd := NewClusterShardsCmd(ctx, "cluster", "shards")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterSlaves
func (c cmdable) ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "cluster", "slaves", nodeID)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ClusterSlots
func (c cmdable) ClusterSlots(ctx context.Context) *ClusterSlotsCmd {
cmd := NewClusterSlotsCmd(ctx, "cluster", "slots")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Command
func (c cmdable) Command(ctx context.Context) *CommandsInfoCmd {
cmd := NewCommandsInfoCmd(ctx, "command")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) CommandGetKeys
func (c cmdable) CommandGetKeys(ctx context.Context, commands ...interface{}) *StringSliceCmd {
args := make([]interface{}, 2+len(commands))
args[0] = "command"
args[1] = "getkeys"
copy(args[2:], commands)
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CommandGetKeysAndFlags
func (c cmdable) CommandGetKeysAndFlags(ctx context.Context, commands ...interface{}) *KeyFlagsCmd {
args := make([]interface{}, 2+len(commands))
args[0] = "command"
args[1] = "getkeysandflags"
copy(args[2:], commands)
cmd := NewKeyFlagsCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) CommandList
func (c cmdable) CommandList(ctx context.Context, filter *FilterBy) *StringSliceCmd {
args := make([]interface{}, 0, 5)
args = append(args, "command", "list")
if filter != nil {
if filter.Module != "" {
args = append(args, "filterby", "module", filter.Module)
} else if filter.ACLCat != "" {
args = append(args, "filterby", "aclcat", filter.ACLCat)
} else if filter.Pattern != "" {
args = append(args, "filterby", "pattern", filter.Pattern)
}
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 9
, Cyclomatic complexity: 5
func (cmdable) ConfigGet
func (c cmdable) ConfigGet(ctx context.Context, parameter string) *MapStringStringCmd {
cmd := NewMapStringStringCmd(ctx, "config", "get", parameter)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ConfigResetStat
func (c cmdable) ConfigResetStat(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "config", "resetstat")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ConfigRewrite
func (c cmdable) ConfigRewrite(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "config", "rewrite")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ConfigSet
func (c cmdable) ConfigSet(ctx context.Context, parameter, value string) *StatusCmd {
cmd := NewStatusCmd(ctx, "config", "set", parameter, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Copy
func (c cmdable) Copy(ctx context.Context, sourceKey, destKey string, db int, replace bool) *IntCmd {
args := []interface{}{"copy", sourceKey, destKey, "DB", db}
if replace {
args = append(args, "REPLACE")
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) DBSize
func (c cmdable) DBSize(ctx context.Context) *IntCmd {
cmd := NewIntCmd(ctx, "dbsize")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) DebugObject
func (c cmdable) DebugObject(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "debug", "object", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Decr
func (c cmdable) Decr(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "decr", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) DecrBy
func (c cmdable) DecrBy(ctx context.Context, key string, decrement int64) *IntCmd {
cmd := NewIntCmd(ctx, "decrby", key, decrement)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Del
func (c cmdable) Del(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "del"
for i, key := range keys {
args[1+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) Dump
func (c cmdable) Dump(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "dump", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Echo
func (c cmdable) Echo(ctx context.Context, message interface{}) *StringCmd {
cmd := NewStringCmd(ctx, "echo", message)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) Exists
func (c cmdable) Exists(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "exists"
for i, key := range keys {
args[1+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) Expire
func (c cmdable) Expire(ctx context.Context, key string, expiration time.Duration) *BoolCmd {
return c.expire(ctx, key, expiration, "")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ExpireAt
func (c cmdable) ExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd {
cmd := NewBoolCmd(ctx, "expireat", key, tm.Unix())
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ExpireGT
func (c cmdable) ExpireGT(ctx context.Context, key string, expiration time.Duration) *BoolCmd {
return c.expire(ctx, key, expiration, "GT")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ExpireLT
func (c cmdable) ExpireLT(ctx context.Context, key string, expiration time.Duration) *BoolCmd {
return c.expire(ctx, key, expiration, "LT")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ExpireNX
func (c cmdable) ExpireNX(ctx context.Context, key string, expiration time.Duration) *BoolCmd {
return c.expire(ctx, key, expiration, "NX")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ExpireTime
func (c cmdable) ExpireTime(ctx context.Context, key string) *DurationCmd {
cmd := NewDurationCmd(ctx, time.Second, "expiretime", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ExpireXX
func (c cmdable) ExpireXX(ctx context.Context, key string, expiration time.Duration) *BoolCmd {
return c.expire(ctx, key, expiration, "XX")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FCall
func (c cmdable) FCall(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd {
cmdArgs := fcallArgs("fcall", function, keys, args...)
cmd := NewCmd(ctx, cmdArgs...)
if len(keys) > 0 {
cmd.SetFirstKeyPos(3)
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (cmdable) FCallRO
func (c cmdable) FCallRO(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd {
cmdArgs := fcallArgs("fcall_ro", function, keys, args...)
cmd := NewCmd(ctx, cmdArgs...)
if len(keys) > 0 {
cmd.SetFirstKeyPos(3)
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (cmdable) FCallRo
FCallRo this function simply calls FCallRO, Deprecated: to maintain convention FCallRO.
func (c cmdable) FCallRo(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd {
return c.FCallRO(ctx, function, keys, args...)
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) FTAggregate
FTAggregate - Performs a search query on an index and applies a series of aggregate transformations to the result. The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query. For more information, please refer to the Redis documentation: [FT.AGGREGATE]: (https://redis.io/commands/ft.aggregate/)
func (c cmdable) FTAggregate(ctx context.Context, index string, query string) *MapStringInterfaceCmd {
args := []interface{}{"FT.AGGREGATE", index, query}
cmd := NewMapStringInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) FTAggregateWithArgs
FTAggregateWithArgs - Performs a search query on an index and applies a series of aggregate transformations to the result. The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query. This function also allows for specifying additional options such as: Verbatim, LoadAll, Load, Timeout, GroupBy, SortBy, SortByMax, Apply, LimitOffset, Limit, Filter, WithCursor, Params, and DialectVersion. For more information, please refer to the Redis documentation: [FT.AGGREGATE]: (https://redis.io/commands/ft.aggregate/)
func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query string, options *FTAggregateOptions) *AggregateCmd {
args := []interface{}{"FT.AGGREGATE", index, query}
if options != nil {
if options.Verbatim {
args = append(args, "VERBATIM")
}
if options.LoadAll && options.Load != nil {
panic("FT.AGGREGATE: LOADALL and LOAD are mutually exclusive")
}
if options.LoadAll {
args = append(args, "LOAD", "*")
}
if options.Load != nil {
args = append(args, "LOAD", len(options.Load))
for _, load := range options.Load {
args = append(args, load.Field)
if load.As != "" {
args = append(args, "AS", load.As)
}
}
}
if options.Timeout > 0 {
args = append(args, "TIMEOUT", options.Timeout)
}
if options.GroupBy != nil {
for _, groupBy := range options.GroupBy {
args = append(args, "GROUPBY", len(groupBy.Fields))
args = append(args, groupBy.Fields...)
for _, reducer := range groupBy.Reduce {
args = append(args, "REDUCE")
args = append(args, reducer.Reducer.String())
if reducer.Args != nil {
args = append(args, len(reducer.Args))
args = append(args, reducer.Args...)
} else {
args = append(args, 0)
}
if reducer.As != "" {
args = append(args, "AS", reducer.As)
}
}
}
}
if options.SortBy != nil {
args = append(args, "SORTBY")
sortByOptions := []interface{}{}
for _, sortBy := range options.SortBy {
sortByOptions = append(sortByOptions, sortBy.FieldName)
if sortBy.Asc && sortBy.Desc {
panic("FT.AGGREGATE: ASC and DESC are mutually exclusive")
}
if sortBy.Asc {
sortByOptions = append(sortByOptions, "ASC")
}
if sortBy.Desc {
sortByOptions = append(sortByOptions, "DESC")
}
}
args = append(args, len(sortByOptions))
args = append(args, sortByOptions...)
}
if options.SortByMax > 0 {
args = append(args, "MAX", options.SortByMax)
}
for _, apply := range options.Apply {
args = append(args, "APPLY", apply.Field)
if apply.As != "" {
args = append(args, "AS", apply.As)
}
}
if options.LimitOffset > 0 {
args = append(args, "LIMIT", options.LimitOffset)
}
if options.Limit > 0 {
args = append(args, options.Limit)
}
if options.Filter != "" {
args = append(args, "FILTER", options.Filter)
}
if options.WithCursor {
args = append(args, "WITHCURSOR")
if options.WithCursorOptions != nil {
if options.WithCursorOptions.Count > 0 {
args = append(args, "COUNT", options.WithCursorOptions.Count)
}
if options.WithCursorOptions.MaxIdle > 0 {
args = append(args, "MAXIDLE", options.WithCursorOptions.MaxIdle)
}
}
}
if options.Params != nil {
args = append(args, "PARAMS", len(options.Params)*2)
for key, value := range options.Params {
args = append(args, key, value)
}
}
if options.DialectVersion > 0 {
args = append(args, "DIALECT", options.DialectVersion)
}
}
cmd := NewAggregateCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 74
, Cyclomatic complexity: 34
func (cmdable) FTAliasAdd
FTAliasAdd - Adds an alias to an index. The 'index' parameter specifies the index to which the alias is added, and the 'alias' parameter specifies the alias. For more information, please refer to the Redis documentation: [FT.ALIASADD]: (https://redis.io/commands/ft.aliasadd/)
func (c cmdable) FTAliasAdd(ctx context.Context, index string, alias string) *StatusCmd {
args := []interface{}{"FT.ALIASADD", alias, index}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) FTAliasDel
FTAliasDel - Removes an alias from an index. The 'alias' parameter specifies the alias to be removed. For more information, please refer to the Redis documentation: [FT.ALIASDEL]: (https://redis.io/commands/ft.aliasdel/)
func (c cmdable) FTAliasDel(ctx context.Context, alias string) *StatusCmd {
cmd := NewStatusCmd(ctx, "FT.ALIASDEL", alias)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTAliasUpdate
FTAliasUpdate - Updates an alias to an index. The 'index' parameter specifies the index to which the alias is updated, and the 'alias' parameter specifies the alias. If the alias already exists for a different index, it updates the alias to point to the specified index instead. For more information, please refer to the Redis documentation: [FT.ALIASUPDATE]: (https://redis.io/commands/ft.aliasupdate/)
func (c cmdable) FTAliasUpdate(ctx context.Context, index string, alias string) *StatusCmd {
cmd := NewStatusCmd(ctx, "FT.ALIASUPDATE", alias, index)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTAlter
FTAlter - Alters the definition of an existing index. The 'index' parameter specifies the index to alter, and the 'skipInitialScan' parameter specifies whether to skip the initial scan. The 'definition' parameter specifies the new definition for the index. For more information, please refer to the Redis documentation: [FT.ALTER]: (https://redis.io/commands/ft.alter/)
func (c cmdable) FTAlter(ctx context.Context, index string, skipInitialScan bool, definition []interface{}) *StatusCmd {
args := []interface{}{"FT.ALTER", index}
if skipInitialScan {
args = append(args, "SKIPINITIALSCAN")
}
args = append(args, "SCHEMA", "ADD")
args = append(args, definition...)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) FTConfigGet
FTConfigGet - Retrieves the value of a RediSearch configuration parameter. The 'option' parameter specifies the configuration parameter to retrieve. For more information, please refer to the Redis documentation: [FT.CONFIG GET]: (https://redis.io/commands/ft.config-get/)
func (c cmdable) FTConfigGet(ctx context.Context, option string) *MapMapStringInterfaceCmd {
cmd := NewMapMapStringInterfaceCmd(ctx, "FT.CONFIG", "GET", option)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTConfigSet
FTConfigSet - Sets the value of a RediSearch configuration parameter. The 'option' parameter specifies the configuration parameter to set, and the 'value' parameter specifies the new value. For more information, please refer to the Redis documentation: [FT.CONFIG SET]: (https://redis.io/commands/ft.config-set/)
func (c cmdable) FTConfigSet(ctx context.Context, option string, value interface{}) *StatusCmd {
cmd := NewStatusCmd(ctx, "FT.CONFIG", "SET", option, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) FTCreate
FTCreate - Creates a new index with the given options and schema. The 'index' parameter specifies the name of the index to create. The 'options' parameter specifies various options for the index, such as: whether to index hashes or JSONs, prefixes, filters, default language, score, score field, payload field, etc. The 'schema' parameter specifies the schema for the index, which includes the field name, field type, etc. For more information, please refer to the Redis documentation: [FT.CREATE]: (https://redis.io/commands/ft.create/)
func (c cmdable) FTCreate(ctx context.Context, index string, options *FTCreateOptions, schema ...*FieldSchema) *StatusCmd {
args := []interface{}{"FT.CREATE", index}
if options != nil {
if options.OnHash && !options.OnJSON {
args = append(args, "ON", "HASH")
}
if options.OnJSON && !options.OnHash {
args = append(args, "ON", "JSON")
}
if options.OnHash && options.OnJSON {
panic("FT.CREATE: ON HASH and ON JSON are mutually exclusive")
}
if options.Prefix != nil {
args = append(args, "PREFIX", len(options.Prefix))
args = append(args, options.Prefix...)
}
if options.Filter != "" {
args = append(args, "FILTER", options.Filter)
}
if options.DefaultLanguage != "" {
args = append(args, "LANGUAGE", options.DefaultLanguage)
}
if options.LanguageField != "" {
args = append(args, "LANGUAGE_FIELD", options.LanguageField)
}
if options.Score > 0 {
args = append(args, "SCORE", options.Score)
}
if options.ScoreField != "" {
args = append(args, "SCORE_FIELD", options.ScoreField)
}
if options.PayloadField != "" {
args = append(args, "PAYLOAD_FIELD", options.PayloadField)
}
if options.MaxTextFields > 0 {
args = append(args, "MAXTEXTFIELDS", options.MaxTextFields)
}
if options.NoOffsets {
args = append(args, "NOOFFSETS")
}
if options.Temporary > 0 {
args = append(args, "TEMPORARY", options.Temporary)
}
if options.NoHL {
args = append(args, "NOHL")
}
if options.NoFields {
args = append(args, "NOFIELDS")
}
if options.NoFreqs {
args = append(args, "NOFREQS")
}
if options.StopWords != nil {
args = append(args, "STOPWORDS", len(options.StopWords))
args = append(args, options.StopWords...)
}
if options.SkipInitialScan {
args = append(args, "SKIPINITIALSCAN")
}
}
if schema == nil {
panic("FT.CREATE: SCHEMA is required")
}
args = append(args, "SCHEMA")
for _, schema := range schema {
if schema.FieldName == "" || schema.FieldType == SearchFieldTypeInvalid {
panic("FT.CREATE: SCHEMA FieldName and FieldType are required")
}
args = append(args, schema.FieldName)
if schema.As != "" {
args = append(args, "AS", schema.As)
}
args = append(args, schema.FieldType.String())
if schema.VectorArgs != nil {
if schema.FieldType != SearchFieldTypeVector {
panic("FT.CREATE: SCHEMA FieldType VECTOR is required for VectorArgs")
}
if schema.VectorArgs.FlatOptions != nil && schema.VectorArgs.HNSWOptions != nil {
panic("FT.CREATE: SCHEMA VectorArgs FlatOptions and HNSWOptions are mutually exclusive")
}
if schema.VectorArgs.FlatOptions != nil {
args = append(args, "FLAT")
if schema.VectorArgs.FlatOptions.Type == "" || schema.VectorArgs.FlatOptions.Dim == 0 || schema.VectorArgs.FlatOptions.DistanceMetric == "" {
panic("FT.CREATE: Type, Dim and DistanceMetric are required for VECTOR FLAT")
}
flatArgs := []interface{}{
"TYPE", schema.VectorArgs.FlatOptions.Type,
"DIM", schema.VectorArgs.FlatOptions.Dim,
"DISTANCE_METRIC", schema.VectorArgs.FlatOptions.DistanceMetric,
}
if schema.VectorArgs.FlatOptions.InitialCapacity > 0 {
flatArgs = append(flatArgs, "INITIAL_CAP", schema.VectorArgs.FlatOptions.InitialCapacity)
}
if schema.VectorArgs.FlatOptions.BlockSize > 0 {
flatArgs = append(flatArgs, "BLOCK_SIZE", schema.VectorArgs.FlatOptions.BlockSize)
}
args = append(args, len(flatArgs))
args = append(args, flatArgs...)
}
if schema.VectorArgs.HNSWOptions != nil {
args = append(args, "HNSW")
if schema.VectorArgs.HNSWOptions.Type == "" || schema.VectorArgs.HNSWOptions.Dim == 0 || schema.VectorArgs.HNSWOptions.DistanceMetric == "" {
panic("FT.CREATE: Type, Dim and DistanceMetric are required for VECTOR HNSW")
}
hnswArgs := []interface{}{
"TYPE", schema.VectorArgs.HNSWOptions.Type,
"DIM", schema.VectorArgs.HNSWOptions.Dim,
"DISTANCE_METRIC", schema.VectorArgs.HNSWOptions.DistanceMetric,
}
if schema.VectorArgs.HNSWOptions.InitialCapacity > 0 {
hnswArgs = append(hnswArgs, "INITIAL_CAP", schema.VectorArgs.HNSWOptions.InitialCapacity)
}
if schema.VectorArgs.HNSWOptions.MaxEdgesPerNode > 0 {
hnswArgs = append(hnswArgs, "M", schema.VectorArgs.HNSWOptions.MaxEdgesPerNode)
}
if schema.VectorArgs.HNSWOptions.MaxAllowedEdgesPerNode > 0 {
hnswArgs = append(hnswArgs, "EF_CONSTRUCTION", schema.VectorArgs.HNSWOptions.MaxAllowedEdgesPerNode)
}
if schema.VectorArgs.HNSWOptions.EFRunTime > 0 {
hnswArgs = append(hnswArgs, "EF_RUNTIME", schema.VectorArgs.HNSWOptions.EFRunTime)
}
if schema.VectorArgs.HNSWOptions.Epsilon > 0 {
hnswArgs = append(hnswArgs, "EPSILON", schema.VectorArgs.HNSWOptions.Epsilon)
}
args = append(args, len(hnswArgs))
args = append(args, hnswArgs...)
}
}
if schema.GeoShapeFieldType != "" {
if schema.FieldType != SearchFieldTypeGeoShape {
panic("FT.CREATE: SCHEMA FieldType GEOSHAPE is required for GeoShapeFieldType")
}
args = append(args, schema.GeoShapeFieldType)
}
if schema.NoStem {
args = append(args, "NOSTEM")
}
if schema.Sortable {
args = append(args, "SORTABLE")
}
if schema.UNF {
args = append(args, "UNF")
}
if schema.NoIndex {
args = append(args, "NOINDEX")
}
if schema.PhoneticMatcher != "" {
args = append(args, "PHONETIC", schema.PhoneticMatcher)
}
if schema.Weight > 0 {
args = append(args, "WEIGHT", schema.Weight)
}
if schema.Separator != "" {
args = append(args, "SEPARATOR", schema.Separator)
}
if schema.CaseSensitive {
args = append(args, "CASESENSITIVE")
}
if schema.WithSuffixtrie {
args = append(args, "WITHSUFFIXTRIE")
}
if schema.IndexEmpty {
args = append(args, "INDEXEMPTY")
}
if schema.IndexMissing {
args = append(args, "INDEXMISSING")
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 107
, Cyclomatic complexity: 60
func (cmdable) FTCursorDel
FTCursorDel - Deletes a cursor from an existing index. The 'index' parameter specifies the index from which to delete the cursor, and the 'cursorId' parameter specifies the ID of the cursor to delete. For more information, please refer to the Redis documentation: [FT.CURSOR DEL]: (https://redis.io/commands/ft.cursor-del/)
func (c cmdable) FTCursorDel(ctx context.Context, index string, cursorId int) *StatusCmd {
cmd := NewStatusCmd(ctx, "FT.CURSOR", "DEL", index, cursorId)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTCursorRead
FTCursorRead - Reads the next results from an existing cursor. The 'index' parameter specifies the index from which to read the cursor, the 'cursorId' parameter specifies the ID of the cursor to read, and the 'count' parameter specifies the number of results to read. For more information, please refer to the Redis documentation: [FT.CURSOR READ]: (https://redis.io/commands/ft.cursor-read/)
func (c cmdable) FTCursorRead(ctx context.Context, index string, cursorId int, count int) *MapStringInterfaceCmd {
args := []interface{}{"FT.CURSOR", "READ", index, cursorId}
if count > 0 {
args = append(args, "COUNT", count)
}
cmd := NewMapStringInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) FTDictAdd
FTDictAdd - Adds terms to a dictionary. The 'dict' parameter specifies the dictionary to which to add the terms, and the 'term' parameter specifies the terms to add. For more information, please refer to the Redis documentation: [FT.DICTADD]: (https://redis.io/commands/ft.dictadd/)
func (c cmdable) FTDictAdd(ctx context.Context, dict string, term ...interface{}) *IntCmd {
args := []interface{}{"FT.DICTADD", dict}
args = append(args, term...)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) FTDictDel
FTDictDel - Deletes terms from a dictionary. The 'dict' parameter specifies the dictionary from which to delete the terms, and the 'term' parameter specifies the terms to delete. For more information, please refer to the Redis documentation: [FT.DICTDEL]: (https://redis.io/commands/ft.dictdel/)
func (c cmdable) FTDictDel(ctx context.Context, dict string, term ...interface{}) *IntCmd {
args := []interface{}{"FT.DICTDEL", dict}
args = append(args, term...)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) FTDictDump
FTDictDump - Returns all terms in the specified dictionary. The 'dict' parameter specifies the dictionary from which to return the terms. For more information, please refer to the Redis documentation: [FT.DICTDUMP]: (https://redis.io/commands/ft.dictdump/)
func (c cmdable) FTDictDump(ctx context.Context, dict string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "FT.DICTDUMP", dict)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTDropIndex
FTDropIndex - Deletes an index. The 'index' parameter specifies the index to delete. For more information, please refer to the Redis documentation: [FT.DROPINDEX]: (https://redis.io/commands/ft.dropindex/)
func (c cmdable) FTDropIndex(ctx context.Context, index string) *StatusCmd {
args := []interface{}{"FT.DROPINDEX", index}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) FTDropIndexWithArgs
FTDropIndexWithArgs - Deletes an index with options. The 'index' parameter specifies the index to delete, and the 'options' parameter specifies the DeleteDocs option for docs deletion. For more information, please refer to the Redis documentation: [FT.DROPINDEX]: (https://redis.io/commands/ft.dropindex/)
func (c cmdable) FTDropIndexWithArgs(ctx context.Context, index string, options *FTDropIndexOptions) *StatusCmd {
args := []interface{}{"FT.DROPINDEX", index}
if options != nil {
if options.DeleteDocs {
args = append(args, "DD")
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) FTExplain
FTExplain - Returns the execution plan for a complex query. The 'index' parameter specifies the index to query, and the 'query' parameter specifies the query string. For more information, please refer to the Redis documentation: [FT.EXPLAIN]: (https://redis.io/commands/ft.explain/)
func (c cmdable) FTExplain(ctx context.Context, index string, query string) *StringCmd {
cmd := NewStringCmd(ctx, "FT.EXPLAIN", index, query)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTExplainCli
FTExplainCli - Returns the execution plan for a complex query. [Not Implemented] For more information, see https://redis.io/commands/ft.explaincli/
func (c cmdable) FTExplainCli(ctx context.Context, key, path string) error {
panic("not implemented")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTExplainWithArgs
FTExplainWithArgs - Returns the execution plan for a complex query with options. The 'index' parameter specifies the index to query, the 'query' parameter specifies the query string, and the 'options' parameter specifies the Dialect for the query. For more information, please refer to the Redis documentation: [FT.EXPLAIN]: (https://redis.io/commands/ft.explain/)
func (c cmdable) FTExplainWithArgs(ctx context.Context, index string, query string, options *FTExplainOptions) *StringCmd {
args := []interface{}{"FT.EXPLAIN", index, query}
if options.Dialect != "" {
args = append(args, "DIALECT", options.Dialect)
}
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) FTInfo
FTInfo - Retrieves information about an index. The 'index' parameter specifies the index to retrieve information about. For more information, please refer to the Redis documentation: [FT.INFO]: (https://redis.io/commands/ft.info/)
func (c cmdable) FTInfo(ctx context.Context, index string) *FTInfoCmd {
cmd := newFTInfoCmd(ctx, "FT.INFO", index)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTSearch
FTSearch - Executes a search query on an index. The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query. For more information, please refer to the Redis documentation: [FT.SEARCH]: (https://redis.io/commands/ft.search/)
func (c cmdable) FTSearch(ctx context.Context, index string, query string) *FTSearchCmd {
args := []interface{}{"FT.SEARCH", index, query}
cmd := newFTSearchCmd(ctx, &FTSearchOptions{}, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) FTSearchWithArgs
FTSearchWithArgs - Executes a search query on an index with additional options. The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query, and the 'options' parameter specifies additional options for the search. For more information, please refer to the Redis documentation: [FT.SEARCH]: (https://redis.io/commands/ft.search/)
func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query string, options *FTSearchOptions) *FTSearchCmd {
args := []interface{}{"FT.SEARCH", index, query}
if options != nil {
if options.NoContent {
args = append(args, "NOCONTENT")
}
if options.Verbatim {
args = append(args, "VERBATIM")
}
if options.NoStopWords {
args = append(args, "NOSTOPWORDS")
}
if options.WithScores {
args = append(args, "WITHSCORES")
}
if options.WithPayloads {
args = append(args, "WITHPAYLOADS")
}
if options.WithSortKeys {
args = append(args, "WITHSORTKEYS")
}
if options.Filters != nil {
for _, filter := range options.Filters {
args = append(args, "FILTER", filter.FieldName, filter.Min, filter.Max)
}
}
if options.GeoFilter != nil {
for _, geoFilter := range options.GeoFilter {
args = append(args, "GEOFILTER", geoFilter.FieldName, geoFilter.Longitude, geoFilter.Latitude, geoFilter.Radius, geoFilter.Unit)
}
}
if options.InKeys != nil {
args = append(args, "INKEYS", len(options.InKeys))
args = append(args, options.InKeys...)
}
if options.InFields != nil {
args = append(args, "INFIELDS", len(options.InFields))
args = append(args, options.InFields...)
}
if options.Return != nil {
args = append(args, "RETURN")
argsReturn := []interface{}{}
for _, ret := range options.Return {
argsReturn = append(argsReturn, ret.FieldName)
if ret.As != "" {
argsReturn = append(argsReturn, "AS", ret.As)
}
}
args = append(args, len(argsReturn))
args = append(args, argsReturn...)
}
if options.Slop > 0 {
args = append(args, "SLOP", options.Slop)
}
if options.Timeout > 0 {
args = append(args, "TIMEOUT", options.Timeout)
}
if options.InOrder {
args = append(args, "INORDER")
}
if options.Language != "" {
args = append(args, "LANGUAGE", options.Language)
}
if options.Expander != "" {
args = append(args, "EXPANDER", options.Expander)
}
if options.Scorer != "" {
args = append(args, "SCORER", options.Scorer)
}
if options.ExplainScore {
args = append(args, "EXPLAINSCORE")
}
if options.Payload != "" {
args = append(args, "PAYLOAD", options.Payload)
}
if options.SortBy != nil {
args = append(args, "SORTBY")
for _, sortBy := range options.SortBy {
args = append(args, sortBy.FieldName)
if sortBy.Asc && sortBy.Desc {
panic("FT.SEARCH: ASC and DESC are mutually exclusive")
}
if sortBy.Asc {
args = append(args, "ASC")
}
if sortBy.Desc {
args = append(args, "DESC")
}
}
if options.SortByWithCount {
args = append(args, "WITHCOUT")
}
}
if options.LimitOffset >= 0 && options.Limit > 0 {
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
}
if options.Params != nil {
args = append(args, "PARAMS", len(options.Params)*2)
for key, value := range options.Params {
args = append(args, key, value)
}
}
if options.DialectVersion > 0 {
args = append(args, "DIALECT", options.DialectVersion)
}
}
cmd := newFTSearchCmd(ctx, options, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 77
, Cyclomatic complexity: 37
func (cmdable) FTSpellCheck
FTSpellCheck - Checks a query string for spelling errors. For more details about spellcheck query please follow: https://redis.io/docs/interact/search-and-query/advanced-concepts/spellcheck/ For more information, please refer to the Redis documentation: [FT.SPELLCHECK]: (https://redis.io/commands/ft.spellcheck/)
func (c cmdable) FTSpellCheck(ctx context.Context, index string, query string) *FTSpellCheckCmd {
args := []interface{}{"FT.SPELLCHECK", index, query}
cmd := newFTSpellCheckCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) FTSpellCheckWithArgs
FTSpellCheckWithArgs - Checks a query string for spelling errors with additional options. For more details about spellcheck query please follow: https://redis.io/docs/interact/search-and-query/advanced-concepts/spellcheck/ For more information, please refer to the Redis documentation: [FT.SPELLCHECK]: (https://redis.io/commands/ft.spellcheck/)
func (c cmdable) FTSpellCheckWithArgs(ctx context.Context, index string, query string, options *FTSpellCheckOptions) *FTSpellCheckCmd {
args := []interface{}{"FT.SPELLCHECK", index, query}
if options != nil {
if options.Distance > 0 {
args = append(args, "DISTANCE", options.Distance)
}
if options.Terms != nil {
args = append(args, "TERMS", options.Terms.Inclusion, options.Terms.Dictionary)
args = append(args, options.Terms.Terms...)
}
if options.Dialect > 0 {
args = append(args, "DIALECT", options.Dialect)
}
}
cmd := newFTSpellCheckCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 10
, Cyclomatic complexity: 5
func (cmdable) FTSynDump
FTSynDump - Dumps the contents of a synonym group. The 'index' parameter specifies the index to dump. For more information, please refer to the Redis documentation: [FT.SYNDUMP]: (https://redis.io/commands/ft.syndump/)
func (c cmdable) FTSynDump(ctx context.Context, index string) *FTSynDumpCmd {
cmd := NewFTSynDumpCmd(ctx, "FT.SYNDUMP", index)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FTSynUpdate
FTSynUpdate - Creates or updates a synonym group with additional terms. The 'index' parameter specifies the index to update, the 'synGroupId' parameter specifies the synonym group id, and the 'terms' parameter specifies the additional terms. For more information, please refer to the Redis documentation: [FT.SYNUPDATE]: (https://redis.io/commands/ft.synupdate/)
func (c cmdable) FTSynUpdate(ctx context.Context, index string, synGroupId interface{}, terms []interface{}) *StatusCmd {
args := []interface{}{"FT.SYNUPDATE", index, synGroupId}
args = append(args, terms...)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 1
func (cmdable) FTSynUpdateWithArgs
FTSynUpdateWithArgs - Creates or updates a synonym group with additional terms and options. The 'index' parameter specifies the index to update, the 'synGroupId' parameter specifies the synonym group id, the 'options' parameter specifies additional options for the update, and the 'terms' parameter specifies the additional terms. For more information, please refer to the Redis documentation: [FT.SYNUPDATE]: (https://redis.io/commands/ft.synupdate/)
func (c cmdable) FTSynUpdateWithArgs(ctx context.Context, index string, synGroupId interface{}, options *FTSynUpdateOptions, terms []interface{}) *StatusCmd {
args := []interface{}{"FT.SYNUPDATE", index, synGroupId}
if options.SkipInitialScan {
args = append(args, "SKIPINITIALSCAN")
}
args = append(args, terms...)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 2
func (cmdable) FTTagVals
FTTagVals - Returns all distinct values indexed in a tag field. The 'index' parameter specifies the index to check, and the 'field' parameter specifies the tag field to retrieve values from. For more information, please refer to the Redis documentation: [FT.TAGVALS]: (https://redis.io/commands/ft.tagvals/)
func (c cmdable) FTTagVals(ctx context.Context, index string, field string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "FT.TAGVALS", index, field)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FT_List
FT_List - Lists all the existing indexes in the database. For more information, please refer to the Redis documentation: [FT._LIST]: (https://redis.io/commands/ft._list/)
func (c cmdable) FT_List(ctx context.Context) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "FT._LIST")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FlushAll
func (c cmdable) FlushAll(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "flushall")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FlushAllAsync
func (c cmdable) FlushAllAsync(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "flushall", "async")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FlushDB
func (c cmdable) FlushDB(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "flushdb")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FlushDBAsync
func (c cmdable) FlushDBAsync(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "flushdb", "async")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionDelete
func (c cmdable) FunctionDelete(ctx context.Context, libName string) *StringCmd {
cmd := NewStringCmd(ctx, "function", "delete", libName)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionDump
func (c cmdable) FunctionDump(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "function", "dump")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionFlush
func (c cmdable) FunctionFlush(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "function", "flush")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionFlushAsync
func (c cmdable) FunctionFlushAsync(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "function", "flush", "async")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionKill
func (c cmdable) FunctionKill(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "function", "kill")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionList
func (c cmdable) FunctionList(ctx context.Context, q FunctionListQuery) *FunctionListCmd {
args := make([]interface{}, 2, 5)
args[0] = "function"
args[1] = "list"
if q.LibraryNamePattern != "" {
args = append(args, "libraryname", q.LibraryNamePattern)
}
if q.WithCode {
args = append(args, "withcode")
}
cmd := NewFunctionListCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 3
func (cmdable) FunctionLoad
func (c cmdable) FunctionLoad(ctx context.Context, code string) *StringCmd {
cmd := NewStringCmd(ctx, "function", "load", code)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionLoadReplace
func (c cmdable) FunctionLoadReplace(ctx context.Context, code string) *StringCmd {
cmd := NewStringCmd(ctx, "function", "load", "replace", code)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionRestore
func (c cmdable) FunctionRestore(ctx context.Context, libDump string) *StringCmd {
cmd := NewStringCmd(ctx, "function", "restore", libDump)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) FunctionStats
func (c cmdable) FunctionStats(ctx context.Context) *FunctionStatsCmd {
cmd := NewFunctionStatsCmd(ctx, "function", "stats")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) GeoAdd
func (c cmdable) GeoAdd(ctx context.Context, key string, geoLocation ...*GeoLocation) *IntCmd {
args := make([]interface{}, 2+3*len(geoLocation))
args[0] = "geoadd"
args[1] = key
for i, eachLoc := range geoLocation {
args[2+3*i] = eachLoc.Longitude
args[2+3*i+1] = eachLoc.Latitude
args[2+3*i+2] = eachLoc.Name
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) GeoDist
func (c cmdable) GeoDist(
ctx context.Context, key string, member1, member2, unit string,
) *FloatCmd {
if unit == "" {
unit = "km"
}
cmd := NewFloatCmd(ctx, "geodist", key, member1, member2, unit)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (cmdable) GeoHash
func (c cmdable) GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd {
args := make([]interface{}, 2+len(members))
args[0] = "geohash"
args[1] = key
for i, member := range members {
args[2+i] = member
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) GeoPos
func (c cmdable) GeoPos(ctx context.Context, key string, members ...string) *GeoPosCmd {
args := make([]interface{}, 2+len(members))
args[0] = "geopos"
args[1] = key
for i, member := range members {
args[2+i] = member
}
cmd := NewGeoPosCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) GeoRadius
GeoRadius is a read-only GEORADIUS_RO command.
func (c cmdable) GeoRadius(
ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery,
) *GeoLocationCmd {
cmd := NewGeoLocationCmd(ctx, query, "georadius_ro", key, longitude, latitude)
if query.Store != "" || query.StoreDist != "" {
cmd.SetErr(errors.New("GeoRadius does not support Store or StoreDist"))
return cmd
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 3
func (cmdable) GeoRadiusByMember
GeoRadiusByMember is a read-only GEORADIUSBYMEMBER_RO command.
func (c cmdable) GeoRadiusByMember(
ctx context.Context, key, member string, query *GeoRadiusQuery,
) *GeoLocationCmd {
cmd := NewGeoLocationCmd(ctx, query, "georadiusbymember_ro", key, member)
if query.Store != "" || query.StoreDist != "" {
cmd.SetErr(errors.New("GeoRadiusByMember does not support Store or StoreDist"))
return cmd
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 3
func (cmdable) GeoRadiusByMemberStore
GeoRadiusByMemberStore is a writing GEORADIUSBYMEMBER command.
func (c cmdable) GeoRadiusByMemberStore(
ctx context.Context, key, member string, query *GeoRadiusQuery,
) *IntCmd {
args := geoLocationArgs(query, "georadiusbymember", key, member)
cmd := NewIntCmd(ctx, args...)
if query.Store == "" && query.StoreDist == "" {
cmd.SetErr(errors.New("GeoRadiusByMemberStore requires Store or StoreDist"))
return cmd
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 3
func (cmdable) GeoRadiusStore
GeoRadiusStore is a writing GEORADIUS command.
func (c cmdable) GeoRadiusStore(
ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery,
) *IntCmd {
args := geoLocationArgs(query, "georadius", key, longitude, latitude)
cmd := NewIntCmd(ctx, args...)
if query.Store == "" && query.StoreDist == "" {
cmd.SetErr(errors.New("GeoRadiusStore requires Store or StoreDist"))
return cmd
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 3
func (cmdable) GeoSearch
func (c cmdable) GeoSearch(ctx context.Context, key string, q *GeoSearchQuery) *StringSliceCmd {
args := make([]interface{}, 0, 13)
args = append(args, "geosearch", key)
args = geoSearchArgs(q, args)
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) GeoSearchLocation
func (c cmdable) GeoSearchLocation(
ctx context.Context, key string, q *GeoSearchLocationQuery,
) *GeoSearchLocationCmd {
args := make([]interface{}, 0, 16)
args = append(args, "geosearch", key)
args = geoSearchLocationArgs(q, args)
cmd := NewGeoSearchLocationCmd(ctx, q, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) GeoSearchStore
func (c cmdable) GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd {
args := make([]interface{}, 0, 15)
args = append(args, "geosearchstore", store, key)
args = geoSearchArgs(&q.GeoSearchQuery, args)
if q.StoreDist {
args = append(args, "storedist")
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (cmdable) GetBit
func (c cmdable) GetBit(ctx context.Context, key string, offset int64) *IntCmd {
cmd := NewIntCmd(ctx, "getbit", key, offset)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) GetDel
GetDel redis-server version >= 6.2.0.
func (c cmdable) GetDel(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "getdel", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) GetEx
GetEx An expiration of zero removes the TTL associated with the key (i.e. GETEX key persist). Requires Redis >= 6.2.0.
func (c cmdable) GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd {
args := make([]interface{}, 0, 4)
args = append(args, "getex", key)
if expiration > 0 {
if usePrecise(expiration) {
args = append(args, "px", formatMs(ctx, expiration))
} else {
args = append(args, "ex", formatSec(ctx, expiration))
}
} else if expiration == 0 {
args = append(args, "persist")
}
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 9
, Cyclomatic complexity: 4
func (cmdable) GetRange
func (c cmdable) GetRange(ctx context.Context, key string, start, end int64) *StringCmd {
cmd := NewStringCmd(ctx, "getrange", key, start, end)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) GetSet
func (c cmdable) GetSet(ctx context.Context, key string, value interface{}) *StringCmd {
cmd := NewStringCmd(ctx, "getset", key, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) HDel
func (c cmdable) HDel(ctx context.Context, key string, fields ...string) *IntCmd {
args := make([]interface{}, 2+len(fields))
args[0] = "hdel"
args[1] = key
for i, field := range fields {
args[2+i] = field
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) HExists
func (c cmdable) HExists(ctx context.Context, key, field string) *BoolCmd {
cmd := NewBoolCmd(ctx, "hexists", key, field)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HExpire
HExpire - Sets the expiration time for specified fields in a hash in seconds. The command constructs an argument list starting with "HEXPIRE", followed by the key, duration, any conditional flags, and the specified fields. For more information - https://redis.io/commands/hexpire/
func (c cmdable) HExpire(ctx context.Context, key string, expiration time.Duration, fields ...string) *IntSliceCmd {
args := []interface{}{"HEXPIRE", key, formatSec(ctx, expiration), "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HExpireAt
HExpireAt - Sets the expiration time for specified fields in a hash to a UNIX timestamp in seconds. Takes a key, a UNIX timestamp, a struct of conditional flags, and a list of fields. The command sets absolute expiration times based on the UNIX timestamp provided. For more information - https://redis.io/commands/hexpireat/
func (c cmdable) HExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) *IntSliceCmd {
args := []interface{}{"HEXPIREAT", key, tm.Unix(), "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HExpireAtWithArgs
func (c cmdable) HExpireAtWithArgs(ctx context.Context, key string, tm time.Time, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd {
args := []interface{}{"HEXPIREAT", key, tm.Unix()}
// only if one argument is true, we can add it to the args
// if more than one argument is true, it will cause an error
if expirationArgs.NX {
args = append(args, "NX")
} else if expirationArgs.XX {
args = append(args, "XX")
} else if expirationArgs.GT {
args = append(args, "GT")
} else if expirationArgs.LT {
args = append(args, "LT")
}
args = append(args, "FIELDS", len(fields))
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 13
, Cyclomatic complexity: 6
func (cmdable) HExpireTime
HExpireTime - Retrieves the expiration time for specified fields in a hash as a UNIX timestamp in seconds. Requires a key and the fields themselves to fetch their expiration timestamps. This command returns the expiration times for each field or error/status codes for each field as specified. For more information - https://redis.io/commands/hexpiretime/
func (c cmdable) HExpireTime(ctx context.Context, key string, fields ...string) *IntSliceCmd {
args := []interface{}{"HEXPIRETIME", key, "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HExpireWithArgs
HExpire - Sets the expiration time for specified fields in a hash in seconds. It requires a key, an expiration duration, a struct with boolean flags for conditional expiration settings (NX, XX, GT, LT), and a list of fields. The command constructs an argument list starting with "HEXPIRE", followed by the key, duration, any conditional flags, and the specified fields. For more information - https://redis.io/commands/hexpire/
func (c cmdable) HExpireWithArgs(ctx context.Context, key string, expiration time.Duration, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd {
args := []interface{}{"HEXPIRE", key, formatSec(ctx, expiration)}
// only if one argument is true, we can add it to the args
// if more than one argument is true, it will cause an error
if expirationArgs.NX {
args = append(args, "NX")
} else if expirationArgs.XX {
args = append(args, "XX")
} else if expirationArgs.GT {
args = append(args, "GT")
} else if expirationArgs.LT {
args = append(args, "LT")
}
args = append(args, "FIELDS", len(fields))
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 13
, Cyclomatic complexity: 6
func (cmdable) HGet
func (c cmdable) HGet(ctx context.Context, key, field string) *StringCmd {
cmd := NewStringCmd(ctx, "hget", key, field)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HGetAll
func (c cmdable) HGetAll(ctx context.Context, key string) *MapStringStringCmd {
cmd := NewMapStringStringCmd(ctx, "hgetall", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HIncrBy
func (c cmdable) HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd {
cmd := NewIntCmd(ctx, "hincrby", key, field, incr)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HIncrByFloat
func (c cmdable) HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd {
cmd := NewFloatCmd(ctx, "hincrbyfloat", key, field, incr)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HKeys
func (c cmdable) HKeys(ctx context.Context, key string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "hkeys", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HLen
func (c cmdable) HLen(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "hlen", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HMGet
HMGet returns the values for the specified fields in the hash stored at key. It returns an interface{} to distinguish between empty string and nil value.
func (c cmdable) HMGet(ctx context.Context, key string, fields ...string) *SliceCmd {
args := make([]interface{}, 2+len(fields))
args[0] = "hmget"
args[1] = key
for i, field := range fields {
args[2+i] = field
}
cmd := NewSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) HMSet
HMSet is a deprecated version of HSet left for compatibility with Redis 3.
func (c cmdable) HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "hmset"
args[1] = key
args = appendArgs(args, values)
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) HPExpire
HPExpire - Sets the expiration time for specified fields in a hash in milliseconds. Similar to HExpire, it accepts a key, an expiration duration in milliseconds, a struct with expiration condition flags, and a list of fields. The command modifies the standard time.Duration to milliseconds for the Redis command. For more information - https://redis.io/commands/hpexpire/
func (c cmdable) HPExpire(ctx context.Context, key string, expiration time.Duration, fields ...string) *IntSliceCmd {
args := []interface{}{"HPEXPIRE", key, formatMs(ctx, expiration), "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HPExpireAt
HPExpireAt - Sets the expiration time for specified fields in a hash to a UNIX timestamp in milliseconds. Similar to HExpireAt but for timestamps in milliseconds. It accepts the same parameters and adjusts the UNIX time to milliseconds. For more information - https://redis.io/commands/hpexpireat/
func (c cmdable) HPExpireAt(ctx context.Context, key string, tm time.Time, fields ...string) *IntSliceCmd {
args := []interface{}{"HPEXPIREAT", key, tm.UnixNano() / int64(time.Millisecond), "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HPExpireAtWithArgs
func (c cmdable) HPExpireAtWithArgs(ctx context.Context, key string, tm time.Time, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd {
args := []interface{}{"HPEXPIREAT", key, tm.UnixNano() / int64(time.Millisecond)}
// only if one argument is true, we can add it to the args
// if more than one argument is true, it will cause an error
if expirationArgs.NX {
args = append(args, "NX")
} else if expirationArgs.XX {
args = append(args, "XX")
} else if expirationArgs.GT {
args = append(args, "GT")
} else if expirationArgs.LT {
args = append(args, "LT")
}
args = append(args, "FIELDS", len(fields))
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 13
, Cyclomatic complexity: 6
func (cmdable) HPExpireTime
HPExpireTime - Retrieves the expiration time for specified fields in a hash as a UNIX timestamp in milliseconds. Similar to HExpireTime, adjusted for timestamps in milliseconds. It requires the same parameters. Provides the expiration timestamp for each field in milliseconds. For more information - https://redis.io/commands/hexpiretime/
func (c cmdable) HPExpireTime(ctx context.Context, key string, fields ...string) *IntSliceCmd {
args := []interface{}{"HPEXPIRETIME", key, "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HPExpireWithArgs
func (c cmdable) HPExpireWithArgs(ctx context.Context, key string, expiration time.Duration, expirationArgs HExpireArgs, fields ...string) *IntSliceCmd {
args := []interface{}{"HPEXPIRE", key, formatMs(ctx, expiration)}
// only if one argument is true, we can add it to the args
// if more than one argument is true, it will cause an error
if expirationArgs.NX {
args = append(args, "NX")
} else if expirationArgs.XX {
args = append(args, "XX")
} else if expirationArgs.GT {
args = append(args, "GT")
} else if expirationArgs.LT {
args = append(args, "LT")
}
args = append(args, "FIELDS", len(fields))
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 13
, Cyclomatic complexity: 6
func (cmdable) HPTTL
HPTTL - Retrieves the remaining time to live for specified fields in a hash in milliseconds. Similar to HTTL, but returns the TTL in milliseconds. It requires a key and the specified fields. This command provides the TTL in milliseconds for each field or returns error/status codes as needed. For more information - https://redis.io/commands/hpttl/
func (c cmdable) HPTTL(ctx context.Context, key string, fields ...string) *IntSliceCmd {
args := []interface{}{"HPTTL", key, "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HPersist
HPersist - Removes the expiration time from specified fields in a hash. Accepts a key and the fields themselves. This command ensures that each field specified will have its expiration removed if present. For more information - https://redis.io/commands/hpersist/
func (c cmdable) HPersist(ctx context.Context, key string, fields ...string) *IntSliceCmd {
args := []interface{}{"HPERSIST", key, "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HRandField
HRandField redis-server version >= 6.2.0.
func (c cmdable) HRandField(ctx context.Context, key string, count int) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "hrandfield", key, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HRandFieldWithValues
HRandFieldWithValues redis-server version >= 6.2.0.
func (c cmdable) HRandFieldWithValues(ctx context.Context, key string, count int) *KeyValueSliceCmd {
cmd := NewKeyValueSliceCmd(ctx, "hrandfield", key, count, "withvalues")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) HScan
func (c cmdable) HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd {
args := []interface{}{"hscan", key, cursor}
if match != "" {
args = append(args, "match", match)
}
if count > 0 {
args = append(args, "count", count)
}
cmd := NewScanCmd(ctx, c, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) HScanNoValues
func (c cmdable) HScanNoValues(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd {
args := []interface{}{"hscan", key, cursor}
if match != "" {
args = append(args, "match", match)
}
if count > 0 {
args = append(args, "count", count)
}
args = append(args, "novalues")
cmd := NewScanCmd(ctx, c, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) HSet
HSet accepts values in following formats:
-
HSet("myhash", "key1", "value1", "key2", "value2")
-
HSet("myhash", []string{"key1", "value1", "key2", "value2"})
-
HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})
Playing struct With "redis" tag. type MyHash struct { Key1 string
redis:"key1"
; Key2 intredis:"key2"
} -
HSet("myhash", MyHash{"value1", "value2"}) Warn: redis-server >= 4.0
For struct, can be a structure pointer type, we only parse the field whose tag is redis. if you don't want the field to be read, you can use the
redis:"-"
flag to ignore it, or you don't need to set the redis tag. For the type of structure field, we only support simple data types: string, int/uint(8,16,32,64), float(32,64), time.Time(to RFC3339Nano), time.Duration(to Nanoseconds ), if you are other more complex or custom data types, please implement the encoding.BinaryMarshaler interface.
Note that in older versions of Redis server(redis-server < 4.0), HSet only supports a single key-value pair. redis-docs: https://redis.io/commands/hset (Starting with Redis version 4.0.0: Accepts multiple field and value arguments.) If you are using a Struct type and the number of fields is greater than one, you will receive an error similar to "ERR wrong number of arguments", you can use HMSet as a substitute.
func (c cmdable) HSet(ctx context.Context, key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "hset"
args[1] = key
args = appendArgs(args, values)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) HSetNX
func (c cmdable) HSetNX(ctx context.Context, key, field string, value interface{}) *BoolCmd {
cmd := NewBoolCmd(ctx, "hsetnx", key, field, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) HTTL
HTTL - Retrieves the remaining time to live for specified fields in a hash in seconds. Requires a key and the fields themselves. It returns the TTL for each specified field. This command fetches the TTL in seconds for each field or returns error/status codes as appropriate. For more information - https://redis.io/commands/httl/
func (c cmdable) HTTL(ctx context.Context, key string, fields ...string) *IntSliceCmd {
args := []interface{}{"HTTL", key, "FIELDS", len(fields)}
for _, field := range fields {
args = append(args, field)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) HVals
func (c cmdable) HVals(ctx context.Context, key string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "hvals", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Incr
func (c cmdable) Incr(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "incr", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) IncrBy
func (c cmdable) IncrBy(ctx context.Context, key string, value int64) *IntCmd {
cmd := NewIntCmd(ctx, "incrby", key, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) IncrByFloat
func (c cmdable) IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd {
cmd := NewFloatCmd(ctx, "incrbyfloat", key, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Info
func (c cmdable) Info(ctx context.Context, sections ...string) *StringCmd {
args := make([]interface{}, 1+len(sections))
args[0] = "info"
for i, section := range sections {
args[i+1] = section
}
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) InfoMap
func (c cmdable) InfoMap(ctx context.Context, sections ...string) *InfoCmd {
args := make([]interface{}, 1+len(sections))
args[0] = "info"
for i, section := range sections {
args[i+1] = section
}
cmd := NewInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) JSONArrAppend
JSONArrAppend adds the provided JSON values to the end of the array at the given path. For more information, see https://redis.io/commands/json.arrappend
func (c cmdable) JSONArrAppend(ctx context.Context, key, path string, values ...interface{}) *IntSliceCmd {
args := []interface{}{"JSON.ARRAPPEND", key, path}
args = append(args, values...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) JSONArrIndex
JSONArrIndex searches for the first occurrence of the provided JSON value in the array at the given path. For more information, see https://redis.io/commands/json.arrindex
func (c cmdable) JSONArrIndex(ctx context.Context, key, path string, value ...interface{}) *IntSliceCmd {
args := []interface{}{"JSON.ARRINDEX", key, path}
args = append(args, value...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) JSONArrIndexWithArgs
JSONArrIndexWithArgs searches for the first occurrence of a JSON value in an array while allowing the start and stop options to be provided. For more information, see https://redis.io/commands/json.arrindex
func (c cmdable) JSONArrIndexWithArgs(ctx context.Context, key, path string, options *JSONArrIndexArgs, value ...interface{}) *IntSliceCmd {
args := []interface{}{"JSON.ARRINDEX", key, path}
args = append(args, value...)
if options != nil {
args = append(args, options.Start)
if options.Stop != nil {
args = append(args, *options.Stop)
}
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 7
, Cyclomatic complexity: 3
func (cmdable) JSONArrInsert
JSONArrInsert inserts the JSON values into the array at the specified path before the index (shifts to the right). For more information, see https://redis.io/commands/json.arrinsert
func (c cmdable) JSONArrInsert(ctx context.Context, key, path string, index int64, values ...interface{}) *IntSliceCmd {
args := []interface{}{"JSON.ARRINSERT", key, path, index}
args = append(args, values...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) JSONArrLen
JSONArrLen reports the length of the JSON array at the specified path in the given key. For more information, see https://redis.io/commands/json.arrlen
func (c cmdable) JSONArrLen(ctx context.Context, key, path string) *IntSliceCmd {
args := []interface{}{"JSON.ARRLEN", key, path}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONArrPop
JSONArrPop removes and returns an element from the specified index in the array. For more information, see https://redis.io/commands/json.arrpop
func (c cmdable) JSONArrPop(ctx context.Context, key, path string, index int) *StringSliceCmd {
args := []interface{}{"JSON.ARRPOP", key, path, index}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONArrTrim
JSONArrTrim trims an array to contain only the specified inclusive range of elements. For more information, see https://redis.io/commands/json.arrtrim
func (c cmdable) JSONArrTrim(ctx context.Context, key, path string) *IntSliceCmd {
args := []interface{}{"JSON.ARRTRIM", key, path}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONArrTrimWithArgs
JSONArrTrimWithArgs trims an array to contain only the specified inclusive range of elements. For more information, see https://redis.io/commands/json.arrtrim
func (c cmdable) JSONArrTrimWithArgs(ctx context.Context, key, path string, options *JSONArrTrimArgs) *IntSliceCmd {
args := []interface{}{"JSON.ARRTRIM", key, path}
if options != nil {
args = append(args, options.Start)
if options.Stop != nil {
args = append(args, *options.Stop)
}
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) JSONClear
JSONClear clears container values (arrays/objects) and sets numeric values to 0. For more information, see https://redis.io/commands/json.clear
func (c cmdable) JSONClear(ctx context.Context, key, path string) *IntCmd {
args := []interface{}{"JSON.CLEAR", key, path}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONDebugMemory
JSONDebugMemory reports a value's memory usage in bytes (unimplemented) For more information, see https://redis.io/commands/json.debug-memory
func (c cmdable) JSONDebugMemory(ctx context.Context, key, path string) *IntCmd {
panic("not implemented")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) JSONDel
JSONDel deletes a value. For more information, see https://redis.io/commands/json.del
func (c cmdable) JSONDel(ctx context.Context, key, path string) *IntCmd {
args := []interface{}{"JSON.DEL", key, path}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONForget
JSONForget deletes a value. For more information, see https://redis.io/commands/json.forget
func (c cmdable) JSONForget(ctx context.Context, key, path string) *IntCmd {
args := []interface{}{"JSON.FORGET", key, path}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONGet
JSONGet returns the value at path in JSON serialized form. JSON.GET returns an array of strings. This function parses out the wrapping array but leaves the internal strings unprocessed by default (see Val()) For more information - https://redis.io/commands/json.get/
func (c cmdable) JSONGet(ctx context.Context, key string, paths ...string) *JSONCmd {
args := make([]interface{}, len(paths)+2)
args[0] = "JSON.GET"
args[1] = key
for n, path := range paths {
args[n+2] = path
}
cmd := newJSONCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) JSONGetWithArgs
JSONGetWithArgs - Retrieves the value of a key from a JSON document. This function also allows for specifying additional options such as: Indention, NewLine and Space For more information - https://redis.io/commands/json.get/
func (c cmdable) JSONGetWithArgs(ctx context.Context, key string, options *JSONGetArgs, paths ...string) *JSONCmd {
args := []interface{}{"JSON.GET", key}
if options != nil {
if options.Indent != "" {
args = append(args, "INDENT", options.Indent)
}
if options.Newline != "" {
args = append(args, "NEWLINE", options.Newline)
}
if options.Space != "" {
args = append(args, "SPACE", options.Space)
}
for _, path := range paths {
args = append(args, path)
}
}
cmd := newJSONCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 13
, Cyclomatic complexity: 6
func (cmdable) JSONMGet
JSONMGet returns the values at the specified path from multiple key arguments.
Note - the arguments are reversed when compared with JSON.MGET
as we want
to follow the pattern of having the last argument be variable.
For more information, see https://redis.io/commands/json.mget
func (c cmdable) JSONMGet(ctx context.Context, path string, keys ...string) *JSONSliceCmd {
args := make([]interface{}, len(keys)+1)
args[0] = "JSON.MGET"
for n, key := range keys {
args[n+1] = key
}
args = append(args, path)
cmd := NewJSONSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) JSONMSet
func (c cmdable) JSONMSet(ctx context.Context, params ...interface{}) *StatusCmd {
args := []interface{}{"JSON.MSET"}
args = append(args, params...)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) JSONMSetArgs
JSONMSetArgs sets or updates one or more JSON values according to the specified key-path-value triplets. For more information, see https://redis.io/commands/json.mset
func (c cmdable) JSONMSetArgs(ctx context.Context, docs []JSONSetArgs) *StatusCmd {
args := []interface{}{"JSON.MSET"}
for _, doc := range docs {
args = append(args, doc.Key, doc.Path, doc.Value)
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) JSONMerge
JSONMerge merges a given JSON value into matching paths. For more information, see https://redis.io/commands/json.merge
func (c cmdable) JSONMerge(ctx context.Context, key, path string, value string) *StatusCmd {
args := []interface{}{"JSON.MERGE", key, path, value}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONNumIncrBy
JSONNumIncrBy increments the number value stored at the specified path by the provided number. For more information, see https://redis.io/docs/latest/commands/json.numincrby/
func (c cmdable) JSONNumIncrBy(ctx context.Context, key, path string, value float64) *JSONCmd {
args := []interface{}{"JSON.NUMINCRBY", key, path, value}
cmd := newJSONCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONObjKeys
JSONObjKeys returns the keys in the object that's referenced by the specified path. For more information, see https://redis.io/commands/json.objkeys
func (c cmdable) JSONObjKeys(ctx context.Context, key, path string) *SliceCmd {
args := []interface{}{"JSON.OBJKEYS", key, path}
cmd := NewSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONObjLen
JSONObjLen reports the number of keys in the JSON object at the specified path in the given key. For more information, see https://redis.io/commands/json.objlen
func (c cmdable) JSONObjLen(ctx context.Context, key, path string) *IntPointerSliceCmd {
args := []interface{}{"JSON.OBJLEN", key, path}
cmd := NewIntPointerSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONSet
JSONSet sets the JSON value at the given path in the given key. The value must be something that can be marshaled to JSON (using encoding/JSON) unless the argument is a string or a []byte when we assume that it can be passed directly as JSON. For more information, see https://redis.io/commands/json.set
func (c cmdable) JSONSet(ctx context.Context, key, path string, value interface{}) *StatusCmd {
return c.JSONSetMode(ctx, key, path, value, "")
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) JSONSetMode
JSONSetMode sets the JSON value at the given path in the given key and allows the mode to be set (the mode value must be "XX" or "NX"). The value must be something that can be marshaled to JSON (using encoding/JSON) unless the argument is a string or []byte when we assume that it can be passed directly as JSON. For more information, see https://redis.io/commands/json.set
func (c cmdable) JSONSetMode(ctx context.Context, key, path string, value interface{}, mode string) *StatusCmd {
var bytes []byte
var err error
switch v := value.(type) {
case string:
bytes = []byte(v)
case []byte:
bytes = v
default:
bytes, err = json.Marshal(v)
}
args := []interface{}{"JSON.SET", key, path, util.BytesToString(bytes)}
if mode != "" {
switch strings.ToUpper(mode) {
case "XX", "NX":
args = append(args, strings.ToUpper(mode))
default:
panic("redis: JSON.SET mode must be NX or XX")
}
}
cmd := NewStatusCmd(ctx, args...)
if err != nil {
cmd.SetErr(err)
} else {
_ = c(ctx, cmd)
}
return cmd
}
Cognitive complexity: 16
, Cyclomatic complexity: 8
func (cmdable) JSONStrAppend
JSONStrAppend appends the JSON-string values to the string at the specified path. For more information, see https://redis.io/commands/json.strappend
func (c cmdable) JSONStrAppend(ctx context.Context, key, path, value string) *IntPointerSliceCmd {
args := []interface{}{"JSON.STRAPPEND", key, path, value}
cmd := NewIntPointerSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONStrLen
JSONStrLen reports the length of the JSON String at the specified path in the given key. For more information, see https://redis.io/commands/json.strlen
func (c cmdable) JSONStrLen(ctx context.Context, key, path string) *IntPointerSliceCmd {
args := []interface{}{"JSON.STRLEN", key, path}
cmd := NewIntPointerSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONToggle
JSONToggle toggles a Boolean value stored at the specified path. For more information, see https://redis.io/commands/json.toggle
func (c cmdable) JSONToggle(ctx context.Context, key, path string) *IntPointerSliceCmd {
args := []interface{}{"JSON.TOGGLE", key, path}
cmd := NewIntPointerSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) JSONType
JSONType reports the type of JSON value at the specified path. For more information, see https://redis.io/commands/json.type
func (c cmdable) JSONType(ctx context.Context, key, path string) *JSONSliceCmd {
args := []interface{}{"JSON.TYPE", key, path}
cmd := NewJSONSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) Keys
func (c cmdable) Keys(ctx context.Context, pattern string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "keys", pattern)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LCS
func (c cmdable) LCS(ctx context.Context, q *LCSQuery) *LCSCmd {
cmd := NewLCSCmd(ctx, q)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LIndex
func (c cmdable) LIndex(ctx context.Context, key string, index int64) *StringCmd {
cmd := NewStringCmd(ctx, "lindex", key, index)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LInsert
func (c cmdable) LInsert(ctx context.Context, key, op string, pivot, value interface{}) *IntCmd {
cmd := NewIntCmd(ctx, "linsert", key, op, pivot, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) LInsertAfter
func (c cmdable) LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd {
cmd := NewIntCmd(ctx, "linsert", key, "after", pivot, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) LInsertBefore
func (c cmdable) LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *IntCmd {
cmd := NewIntCmd(ctx, "linsert", key, "before", pivot, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) LLen
func (c cmdable) LLen(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "llen", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LMPop
LMPop Pops one or more elements from the first non-empty list key from the list of provided key names. direction: left or right, count: > 0 example: client.LMPop(ctx, "left", 3, "key1", "key2")
func (c cmdable) LMPop(ctx context.Context, direction string, count int64, keys ...string) *KeyValuesCmd {
args := make([]interface{}, 2+len(keys), 5+len(keys))
args[0] = "lmpop"
args[1] = len(keys)
for i, key := range keys {
args[2+i] = key
}
args = append(args, strings.ToLower(direction), "count", count)
cmd := NewKeyValuesCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) LMove
func (c cmdable) LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd {
cmd := NewStringCmd(ctx, "lmove", source, destination, srcpos, destpos)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LPop
func (c cmdable) LPop(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "lpop", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LPopCount
func (c cmdable) LPopCount(ctx context.Context, key string, count int) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "lpop", key, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LPos
func (c cmdable) LPos(ctx context.Context, key string, value string, a LPosArgs) *IntCmd {
args := []interface{}{"lpos", key, value}
if a.Rank != 0 {
args = append(args, "rank", a.Rank)
}
if a.MaxLen != 0 {
args = append(args, "maxlen", a.MaxLen)
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) LPosCount
func (c cmdable) LPosCount(ctx context.Context, key string, value string, count int64, a LPosArgs) *IntSliceCmd {
args := []interface{}{"lpos", key, value, "count", count}
if a.Rank != 0 {
args = append(args, "rank", a.Rank)
}
if a.MaxLen != 0 {
args = append(args, "maxlen", a.MaxLen)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) LPush
func (c cmdable) LPush(ctx context.Context, key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "lpush"
args[1] = key
args = appendArgs(args, values)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) LPushX
func (c cmdable) LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "lpushx"
args[1] = key
args = appendArgs(args, values)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) LRange
func (c cmdable) LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd {
cmd := NewStringSliceCmd(
ctx,
"lrange",
key,
start,
stop,
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LRem
func (c cmdable) LRem(ctx context.Context, key string, count int64, value interface{}) *IntCmd {
cmd := NewIntCmd(ctx, "lrem", key, count, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) LSet
func (c cmdable) LSet(ctx context.Context, key string, index int64, value interface{}) *StatusCmd {
cmd := NewStatusCmd(ctx, "lset", key, index, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) LTrim
func (c cmdable) LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd {
cmd := NewStatusCmd(
ctx,
"ltrim",
key,
start,
stop,
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) LastSave
func (c cmdable) LastSave(ctx context.Context) *IntCmd {
cmd := NewIntCmd(ctx, "lastsave")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) MGet
func (c cmdable) MGet(ctx context.Context, keys ...string) *SliceCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "mget"
for i, key := range keys {
args[1+i] = key
}
cmd := NewSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) MSet
MSet is like Set but accepts multiple values:
- MSet("key1", "value1", "key2", "value2")
- MSet([]string{"key1", "value1", "key2", "value2"})
- MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})
- MSet(struct), For struct types, see HSet description.
func (c cmdable) MSet(ctx context.Context, values ...interface{}) *StatusCmd {
args := make([]interface{}, 1, 1+len(values))
args[0] = "mset"
args = appendArgs(args, values)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) MSetNX
MSetNX is like SetNX but accepts multiple values:
- MSetNX("key1", "value1", "key2", "value2")
- MSetNX([]string{"key1", "value1", "key2", "value2"})
- MSetNX(map[string]interface{}{"key1": "value1", "key2": "value2"})
- MSetNX(struct), For struct types, see HSet description.
func (c cmdable) MSetNX(ctx context.Context, values ...interface{}) *BoolCmd {
args := make([]interface{}, 1, 1+len(values))
args[0] = "msetnx"
args = appendArgs(args, values)
cmd := NewBoolCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) MemoryUsage
func (c cmdable) MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd {
args := []interface{}{"memory", "usage", key}
if len(samples) > 0 {
if len(samples) != 1 {
panic("MemoryUsage expects single sample count")
}
args = append(args, "SAMPLES", samples[0])
}
cmd := NewIntCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) Migrate
func (c cmdable) Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd {
cmd := NewStatusCmd(
ctx,
"migrate",
host,
port,
key,
db,
formatMs(ctx, timeout),
)
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ModuleLoadex
ModuleLoadex Redis MODULE LOADEX path [CONFIG name value [CONFIG name value ...]] [ARGS args [args ...]]
command.
func (c cmdable) ModuleLoadex(ctx context.Context, conf *ModuleLoadexConfig) *StringCmd {
cmd := NewStringCmd(ctx, conf.toArgs()...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Monitor
Monitor - represents a Redis MONITOR command, allowing the user to capture and process all commands sent to a Redis server. This mimics the behavior of MONITOR in the redis-cli.
Notes:
- Using MONITOR blocks the connection to the server for itself. It needs a dedicated connection
- The user should create a channel of type string
- This runs concurrently in the background. Trigger via the Start and Stop functions See further: Redis MONITOR command: https://redis.io/commands/monitor
/*
Monitor - represents a Redis MONITOR command, allowing the user to capture
and process all commands sent to a Redis server. This mimics the behavior of
MONITOR in the redis-cli.
Notes:
- Using MONITOR blocks the connection to the server for itself. It needs a dedicated connection
- The user should create a channel of type string
- This runs concurrently in the background. Trigger via the Start and Stop functions
See further: Redis MONITOR command: https://redis.io/commands/monitor
*/
func (c cmdable) Monitor(ctx context.Context, ch chan string) *MonitorCmd {
cmd := newMonitorCmd(ctx, ch)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Move
func (c cmdable) Move(ctx context.Context, key string, db int) *BoolCmd {
cmd := NewBoolCmd(ctx, "move", key, db)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ObjectEncoding
func (c cmdable) ObjectEncoding(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "object", "encoding", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ObjectFreq
func (c cmdable) ObjectFreq(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "object", "freq", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ObjectIdleTime
func (c cmdable) ObjectIdleTime(ctx context.Context, key string) *DurationCmd {
cmd := NewDurationCmd(ctx, time.Second, "object", "idletime", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ObjectRefCount
func (c cmdable) ObjectRefCount(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "object", "refcount", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) PExpire
func (c cmdable) PExpire(ctx context.Context, key string, expiration time.Duration) *BoolCmd {
cmd := NewBoolCmd(ctx, "pexpire", key, formatMs(ctx, expiration))
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) PExpireAt
func (c cmdable) PExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd {
cmd := NewBoolCmd(
ctx,
"pexpireat",
key,
tm.UnixNano()/int64(time.Millisecond),
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) PExpireTime
func (c cmdable) PExpireTime(ctx context.Context, key string) *DurationCmd {
cmd := NewDurationCmd(ctx, time.Millisecond, "pexpiretime", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) PFAdd
func (c cmdable) PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(els))
args[0] = "pfadd"
args[1] = key
args = appendArgs(args, els)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) PFCount
func (c cmdable) PFCount(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "pfcount"
for i, key := range keys {
args[1+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) PFMerge
func (c cmdable) PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "pfmerge"
args[1] = dest
for i, key := range keys {
args[2+i] = key
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) PTTL
func (c cmdable) PTTL(ctx context.Context, key string) *DurationCmd {
cmd := NewDurationCmd(ctx, time.Millisecond, "pttl", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Persist
func (c cmdable) Persist(ctx context.Context, key string) *BoolCmd {
cmd := NewBoolCmd(ctx, "persist", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Ping
func (c cmdable) Ping(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "ping")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) PubSubChannels
func (c cmdable) PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd {
args := []interface{}{"pubsub", "channels"}
if pattern != "*" {
args = append(args, pattern)
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) PubSubNumPat
func (c cmdable) PubSubNumPat(ctx context.Context) *IntCmd {
cmd := NewIntCmd(ctx, "pubsub", "numpat")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) PubSubNumSub
func (c cmdable) PubSubNumSub(ctx context.Context, channels ...string) *MapStringIntCmd {
args := make([]interface{}, 2+len(channels))
args[0] = "pubsub"
args[1] = "numsub"
for i, channel := range channels {
args[2+i] = channel
}
cmd := NewMapStringIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) PubSubShardChannels
func (c cmdable) PubSubShardChannels(ctx context.Context, pattern string) *StringSliceCmd {
args := []interface{}{"pubsub", "shardchannels"}
if pattern != "*" {
args = append(args, pattern)
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) PubSubShardNumSub
func (c cmdable) PubSubShardNumSub(ctx context.Context, channels ...string) *MapStringIntCmd {
args := make([]interface{}, 2+len(channels))
args[0] = "pubsub"
args[1] = "shardnumsub"
for i, channel := range channels {
args[2+i] = channel
}
cmd := NewMapStringIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) Publish
Publish posts the message to the channel.
func (c cmdable) Publish(ctx context.Context, channel string, message interface{}) *IntCmd {
cmd := NewIntCmd(ctx, "publish", channel, message)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) Quit
func (c cmdable) Quit(_ context.Context) *StatusCmd {
panic("not implemented")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) RPop
func (c cmdable) RPop(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "rpop", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) RPopCount
func (c cmdable) RPopCount(ctx context.Context, key string, count int) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "rpop", key, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) RPopLPush
func (c cmdable) RPopLPush(ctx context.Context, source, destination string) *StringCmd {
cmd := NewStringCmd(ctx, "rpoplpush", source, destination)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) RPush
func (c cmdable) RPush(ctx context.Context, key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "rpush"
args[1] = key
args = appendArgs(args, values)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) RPushX
func (c cmdable) RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "rpushx"
args[1] = key
args = appendArgs(args, values)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) RandomKey
func (c cmdable) RandomKey(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "randomkey")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ReadOnly
func (c cmdable) ReadOnly(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "readonly")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ReadWrite
func (c cmdable) ReadWrite(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "readwrite")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Rename
func (c cmdable) Rename(ctx context.Context, key, newkey string) *StatusCmd {
cmd := NewStatusCmd(ctx, "rename", key, newkey)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) RenameNX
func (c cmdable) RenameNX(ctx context.Context, key, newkey string) *BoolCmd {
cmd := NewBoolCmd(ctx, "renamenx", key, newkey)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Restore
func (c cmdable) Restore(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd {
cmd := NewStatusCmd(
ctx,
"restore",
key,
formatMs(ctx, ttl),
value,
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) RestoreReplace
func (c cmdable) RestoreReplace(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd {
cmd := NewStatusCmd(
ctx,
"restore",
key,
formatMs(ctx, ttl),
value,
"replace",
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SAdd
func (c cmdable) SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(members))
args[0] = "sadd"
args[1] = key
args = appendArgs(args, members)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) SCard
func (c cmdable) SCard(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "scard", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SDiff
func (c cmdable) SDiff(ctx context.Context, keys ...string) *StringSliceCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "sdiff"
for i, key := range keys {
args[1+i] = key
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) SDiffStore
func (c cmdable) SDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "sdiffstore"
args[1] = destination
for i, key := range keys {
args[2+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) SInter
func (c cmdable) SInter(ctx context.Context, keys ...string) *StringSliceCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "sinter"
for i, key := range keys {
args[1+i] = key
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) SInterCard
func (c cmdable) SInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd {
args := make([]interface{}, 4+len(keys))
args[0] = "sintercard"
numkeys := int64(0)
for i, key := range keys {
args[2+i] = key
numkeys++
}
args[1] = numkeys
args[2+numkeys] = "limit"
args[3+numkeys] = limit
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) SInterStore
func (c cmdable) SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "sinterstore"
args[1] = destination
for i, key := range keys {
args[2+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) SIsMember
func (c cmdable) SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd {
cmd := NewBoolCmd(ctx, "sismember", key, member)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) SMIsMember
SMIsMember Redis SMISMEMBER key member [member ...]
command.
func (c cmdable) SMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmd {
args := make([]interface{}, 2, 2+len(members))
args[0] = "smismember"
args[1] = key
args = appendArgs(args, members)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) SMembers
SMembers Redis SMEMBERS key
command output as a slice.
func (c cmdable) SMembers(ctx context.Context, key string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "smembers", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SMembersMap
SMembersMap Redis SMEMBERS key
command output as a map.
func (c cmdable) SMembersMap(ctx context.Context, key string) *StringStructMapCmd {
cmd := NewStringStructMapCmd(ctx, "smembers", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SMove
func (c cmdable) SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd {
cmd := NewBoolCmd(ctx, "smove", source, destination, member)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) SPop
SPop Redis SPOP key
command.
func (c cmdable) SPop(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "spop", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SPopN
SPopN Redis SPOP key count
command.
func (c cmdable) SPopN(ctx context.Context, key string, count int64) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "spop", key, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SPublish
func (c cmdable) SPublish(ctx context.Context, channel string, message interface{}) *IntCmd {
cmd := NewIntCmd(ctx, "spublish", channel, message)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) SRandMember
SRandMember Redis SRANDMEMBER key
command.
func (c cmdable) SRandMember(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "srandmember", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SRandMemberN
SRandMemberN Redis SRANDMEMBER key count
command.
func (c cmdable) SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "srandmember", key, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SRem
func (c cmdable) SRem(ctx context.Context, key string, members ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(members))
args[0] = "srem"
args[1] = key
args = appendArgs(args, members)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) SScan
func (c cmdable) SScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd {
args := []interface{}{"sscan", key, cursor}
if match != "" {
args = append(args, "match", match)
}
if count > 0 {
args = append(args, "count", count)
}
cmd := NewScanCmd(ctx, c, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) SUnion
func (c cmdable) SUnion(ctx context.Context, keys ...string) *StringSliceCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "sunion"
for i, key := range keys {
args[1+i] = key
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) SUnionStore
func (c cmdable) SUnionStore(ctx context.Context, destination string, keys ...string) *IntCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "sunionstore"
args[1] = destination
for i, key := range keys {
args[2+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) Save
func (c cmdable) Save(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "save")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ScanType
func (c cmdable) ScanType(ctx context.Context, cursor uint64, match string, count int64, keyType string) *ScanCmd {
args := []interface{}{"scan", cursor}
if match != "" {
args = append(args, "match", match)
}
if count > 0 {
args = append(args, "count", count)
}
if keyType != "" {
args = append(args, "type", keyType)
}
cmd := NewScanCmd(ctx, c, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (cmdable) ScriptKill
func (c cmdable) ScriptKill(ctx context.Context) *StatusCmd {
cmd := NewStatusCmd(ctx, "script", "kill")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SetArgs
SetArgs supports all the options that the SET command supports. It is the alternative to the Set function when you want to have more control over the options.
func (c cmdable) SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd {
args := []interface{}{"set", key, value}
if a.KeepTTL {
args = append(args, "keepttl")
}
if !a.ExpireAt.IsZero() {
args = append(args, "exat", a.ExpireAt.Unix())
}
if a.TTL > 0 {
if usePrecise(a.TTL) {
args = append(args, "px", formatMs(ctx, a.TTL))
} else {
args = append(args, "ex", formatSec(ctx, a.TTL))
}
}
if a.Mode != "" {
args = append(args, a.Mode)
}
if a.Get {
args = append(args, "get")
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 17
, Cyclomatic complexity: 7
func (cmdable) SetBit
func (c cmdable) SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd {
cmd := NewIntCmd(
ctx,
"setbit",
key,
offset,
value,
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SetEx
SetEx Redis SETEx key expiration value
command.
func (c cmdable) SetEx(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd {
cmd := NewStatusCmd(ctx, "setex", key, formatSec(ctx, expiration), value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) SetNX
SetNX Redis SET key value [expiration] NX
command.
Zero expiration means the key has no expiration time. KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0, otherwise you will receive an error: (error) ERR syntax error.
func (c cmdable) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd {
var cmd *BoolCmd
switch expiration {
case 0:
// Use old `SETNX` to support old Redis versions.
cmd = NewBoolCmd(ctx, "setnx", key, value)
case KeepTTL:
cmd = NewBoolCmd(ctx, "set", key, value, "keepttl", "nx")
default:
if usePrecise(expiration) {
cmd = NewBoolCmd(ctx, "set", key, value, "px", formatMs(ctx, expiration), "nx")
} else {
cmd = NewBoolCmd(ctx, "set", key, value, "ex", formatSec(ctx, expiration), "nx")
}
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 9
, Cyclomatic complexity: 5
func (cmdable) SetRange
func (c cmdable) SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd {
cmd := NewIntCmd(ctx, "setrange", key, offset, value)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SetXX
SetXX Redis SET key value [expiration] XX
command.
Zero expiration means the key has no expiration time. KeepTTL is a Redis KEEPTTL option to keep existing TTL, it requires your redis-server version >= 6.0, otherwise you will receive an error: (error) ERR syntax error.
func (c cmdable) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd {
var cmd *BoolCmd
switch expiration {
case 0:
cmd = NewBoolCmd(ctx, "set", key, value, "xx")
case KeepTTL:
cmd = NewBoolCmd(ctx, "set", key, value, "keepttl", "xx")
default:
if usePrecise(expiration) {
cmd = NewBoolCmd(ctx, "set", key, value, "px", formatMs(ctx, expiration), "xx")
} else {
cmd = NewBoolCmd(ctx, "set", key, value, "ex", formatSec(ctx, expiration), "xx")
}
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 9
, Cyclomatic complexity: 5
func (cmdable) Shutdown
func (c cmdable) Shutdown(ctx context.Context) *StatusCmd {
return c.shutdown(ctx, "")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ShutdownNoSave
func (c cmdable) ShutdownNoSave(ctx context.Context) *StatusCmd {
return c.shutdown(ctx, "nosave")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ShutdownSave
func (c cmdable) ShutdownSave(ctx context.Context) *StatusCmd {
return c.shutdown(ctx, "save")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SlaveOf
func (c cmdable) SlaveOf(ctx context.Context, host, port string) *StatusCmd {
cmd := NewStatusCmd(ctx, "slaveof", host, port)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SlowLogGet
func (c cmdable) SlowLogGet(ctx context.Context, num int64) *SlowLogCmd {
cmd := NewSlowLogCmd(context.Background(), "slowlog", "get", num)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Sort
func (c cmdable) Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, sort.args("sort", key)...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SortInterfaces
func (c cmdable) SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd {
cmd := NewSliceCmd(ctx, sort.args("sort", key)...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SortRO
func (c cmdable) SortRO(ctx context.Context, key string, sort *Sort) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, sort.args("sort_ro", key)...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) SortStore
func (c cmdable) SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd {
args := sort.args("sort", key)
if store != "" {
args = append(args, "store", store)
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 2
func (cmdable) StrLen
func (c cmdable) StrLen(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "strlen", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Sync
func (c cmdable) Sync(_ context.Context) {
panic("not implemented")
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) TDigestAdd
TDigestAdd adds one or more elements to a t-Digest data structure. Returns OK on success or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.add/
func (c cmdable) TDigestAdd(ctx context.Context, key string, elements ...float64) *StatusCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TDIGEST.ADD"
args[1] = key
// Convert floatSlice to []interface{}
interfaceSlice := make([]interface{}, len(elements))
for i, v := range elements {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestByRank
TDigestByRank returns an array of values from a t-Digest data structure based on their rank. The rank of an element is its position in the sorted list of all elements in the t-Digest. Returns an array of floats representing the values at the specified ranks or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.byrank/
func (c cmdable) TDigestByRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd {
args := make([]interface{}, 2, 2+len(rank))
args[0] = "TDIGEST.BYRANK"
args[1] = key
// Convert uint slice to []interface{}
interfaceSlice := make([]interface{}, len(rank))
for i, v := range rank {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewFloatSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestByRevRank
TDigestByRevRank returns an array of values from a t-Digest data structure based on their reverse rank. The reverse rank of an element is its position in the sorted list of all elements in the t-Digest when sorted in descending order. Returns an array of floats representing the values at the specified ranks or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.byrevrank/
func (c cmdable) TDigestByRevRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd {
args := make([]interface{}, 2, 2+len(rank))
args[0] = "TDIGEST.BYREVRANK"
args[1] = key
// Convert uint slice to []interface{}
interfaceSlice := make([]interface{}, len(rank))
for i, v := range rank {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewFloatSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestCDF
TDigestCDF returns an array of cumulative distribution function (CDF) values for one or more elements in a t-Digest data structure. The CDF value for an element is the fraction of all elements in the t-Digest that are less than or equal to it. Returns an array of floats representing the CDF values for each element or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.cdf/
func (c cmdable) TDigestCDF(ctx context.Context, key string, elements ...float64) *FloatSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TDIGEST.CDF"
args[1] = key
// Convert floatSlice to []interface{}
interfaceSlice := make([]interface{}, len(elements))
for i, v := range elements {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewFloatSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestCreate
TDigestCreate creates an empty t-Digest data structure with default parameters. Returns OK on success or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.create/
func (c cmdable) TDigestCreate(ctx context.Context, key string) *StatusCmd {
args := []interface{}{"TDIGEST.CREATE", key}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TDigestCreateWithCompression
TDigestCreateWithCompression creates an empty t-Digest data structure with a specified compression parameter. The compression parameter controls the accuracy and memory usage of the t-Digest. Returns OK on success or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.create/
func (c cmdable) TDigestCreateWithCompression(ctx context.Context, key string, compression int64) *StatusCmd {
args := []interface{}{"TDIGEST.CREATE", key, "COMPRESSION", compression}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TDigestInfo
TDigestInfo returns information about a t-Digest data structure. For more information - https://redis.io/commands/tdigest.info/
func (c cmdable) TDigestInfo(ctx context.Context, key string) *TDigestInfoCmd {
args := []interface{}{"TDIGEST.INFO", key}
cmd := NewTDigestInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TDigestMax
TDigestMax returns the maximum value from a t-Digest data structure. For more information - https://redis.io/commands/tdigest.max/
func (c cmdable) TDigestMax(ctx context.Context, key string) *FloatCmd {
args := []interface{}{"TDIGEST.MAX", key}
cmd := NewFloatCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TDigestMerge
TDigestMerge merges multiple t-Digest data structures into a single t-Digest. This function also allows for specifying additional options such as compression and override behavior. Returns OK on success or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.merge/
func (c cmdable) TDigestMerge(ctx context.Context, destKey string, options *TDigestMergeOptions, sourceKeys ...string) *StatusCmd {
args := []interface{}{"TDIGEST.MERGE", destKey, len(sourceKeys)}
for _, sourceKey := range sourceKeys {
args = append(args, sourceKey)
}
if options != nil {
if options.Compression != 0 {
args = append(args, "COMPRESSION", options.Compression)
}
if options.Override {
args = append(args, "OVERRIDE")
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 11
, Cyclomatic complexity: 5
func (cmdable) TDigestMin
TDigestMin returns the minimum value from a t-Digest data structure. For more information - https://redis.io/commands/tdigest.min/
func (c cmdable) TDigestMin(ctx context.Context, key string) *FloatCmd {
args := []interface{}{"TDIGEST.MIN", key}
cmd := NewFloatCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TDigestQuantile
TDigestQuantile returns an array of quantile values for one or more elements in a t-Digest data structure. The quantile value for an element is the fraction of all elements in the t-Digest that are less than or equal to it. Returns an array of floats representing the quantile values for each element or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.quantile/
func (c cmdable) TDigestQuantile(ctx context.Context, key string, elements ...float64) *FloatSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TDIGEST.QUANTILE"
args[1] = key
// Convert floatSlice to []interface{}
interfaceSlice := make([]interface{}, len(elements))
for i, v := range elements {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewFloatSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestRank
TDigestRank returns an array of rank values for one or more elements in a t-Digest data structure. The rank of an element is its position in the sorted list of all elements in the t-Digest. Returns an array of integers representing the rank values for each element or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.rank/
func (c cmdable) TDigestRank(ctx context.Context, key string, values ...float64) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "TDIGEST.RANK"
args[1] = key
// Convert floatSlice to []interface{}
interfaceSlice := make([]interface{}, len(values))
for i, v := range values {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestReset
TDigestReset resets a t-Digest data structure to its initial state. Returns OK on success or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.reset/
func (c cmdable) TDigestReset(ctx context.Context, key string) *StatusCmd {
args := []interface{}{"TDIGEST.RESET", key}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TDigestRevRank
TDigestRevRank returns an array of reverse rank values for one or more elements in a t-Digest data structure. The reverse rank of an element is its position in the sorted list of all elements in the t-Digest when sorted in descending order. Returns an array of integers representing the reverse rank values for each element or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.revrank/
func (c cmdable) TDigestRevRank(ctx context.Context, key string, values ...float64) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(values))
args[0] = "TDIGEST.REVRANK"
args[1] = key
// Convert floatSlice to []interface{}
interfaceSlice := make([]interface{}, len(values))
for i, v := range values {
interfaceSlice[i] = v
}
args = append(args, interfaceSlice...)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TDigestTrimmedMean
TDigestTrimmedMean returns the trimmed mean value from a t-Digest data structure. The trimmed mean is calculated by removing a specified fraction of the highest and lowest values from the t-Digest and then calculating the mean of the remaining values. Returns a float representing the trimmed mean value or an error if the operation could not be completed. For more information - https://redis.io/commands/tdigest.trimmed_mean/
func (c cmdable) TDigestTrimmedMean(ctx context.Context, key string, lowCutQuantile, highCutQuantile float64) *FloatCmd {
args := []interface{}{"TDIGEST.TRIMMED_MEAN", key, lowCutQuantile, highCutQuantile}
cmd := NewFloatCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TFCall
TFCall - invoke a function. For more information - https://redis.io/commands/tfcall/
func (c cmdable) TFCall(ctx context.Context, libName string, funcName string, numKeys int) *Cmd {
lf := libName + "." + funcName
args := []interface{}{"TFCALL", lf, numKeys}
cmd := NewCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TFCallASYNC
TFCallASYNC - invoke an asynchronous JavaScript function (coroutine). For more information - https://redis.io/commands/TFCallASYNC/
func (c cmdable) TFCallASYNC(ctx context.Context, libName string, funcName string, numKeys int) *Cmd {
lf := fmt.Sprintf("%s.%s", libName, funcName)
args := []interface{}{"TFCALLASYNC", lf, numKeys}
cmd := NewCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TFCallASYNCArgs
func (c cmdable) TFCallASYNCArgs(ctx context.Context, libName string, funcName string, numKeys int, options *TFCallOptions) *Cmd {
lf := fmt.Sprintf("%s.%s", libName, funcName)
args := []interface{}{"TFCALLASYNC", lf, numKeys}
if options != nil {
for _, key := range options.Keys {
args = append(args, key)
}
for _, key := range options.Arguments {
args = append(args, key)
}
}
cmd := NewCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 10
, Cyclomatic complexity: 4
func (cmdable) TFCallArgs
func (c cmdable) TFCallArgs(ctx context.Context, libName string, funcName string, numKeys int, options *TFCallOptions) *Cmd {
lf := libName + "." + funcName
args := []interface{}{"TFCALL", lf, numKeys}
if options != nil {
for _, key := range options.Keys {
args = append(args, key)
}
for _, key := range options.Arguments {
args = append(args, key)
}
}
cmd := NewCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 10
, Cyclomatic complexity: 4
func (cmdable) TFunctionDelete
TFunctionDelete - delete a JavaScript library from Redis. For more information - https://redis.io/commands/tfunction-delete/
func (c cmdable) TFunctionDelete(ctx context.Context, libName string) *StatusCmd {
args := []interface{}{"TFUNCTION", "DELETE", libName}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TFunctionList
TFunctionList - list the functions with additional information about each function. For more information - https://redis.io/commands/tfunction-list/
func (c cmdable) TFunctionList(ctx context.Context) *MapStringInterfaceSliceCmd {
args := []interface{}{"TFUNCTION", "LIST"}
cmd := NewMapStringInterfaceSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TFunctionListArgs
func (c cmdable) TFunctionListArgs(ctx context.Context, options *TFunctionListOptions) *MapStringInterfaceSliceCmd {
args := []interface{}{"TFUNCTION", "LIST"}
if options != nil {
if options.Withcode {
args = append(args, "WITHCODE")
}
if options.Verbose != 0 {
v := strings.Repeat("v", options.Verbose)
args = append(args, v)
}
if options.Library != "" {
args = append(args, "LIBRARY", options.Library)
}
}
cmd := NewMapStringInterfaceSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 10
, Cyclomatic complexity: 5
func (cmdable) TFunctionLoad
TFunctionLoad - load a new JavaScript library into Redis. For more information - https://redis.io/commands/tfunction-load/
func (c cmdable) TFunctionLoad(ctx context.Context, lib string) *StatusCmd {
args := []interface{}{"TFUNCTION", "LOAD", lib}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TFunctionLoadArgs
func (c cmdable) TFunctionLoadArgs(ctx context.Context, lib string, options *TFunctionLoadOptions) *StatusCmd {
args := []interface{}{"TFUNCTION", "LOAD"}
if options != nil {
if options.Replace {
args = append(args, "REPLACE")
}
if options.Config != "" {
args = append(args, "CONFIG", options.Config)
}
}
args = append(args, lib)
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 8
, Cyclomatic complexity: 4
func (cmdable) TSAdd
TSAdd - Adds one or more observations to a t-digest sketch. For more information - https://redis.io/commands/ts.add/
func (c cmdable) TSAdd(ctx context.Context, key string, timestamp interface{}, value float64) *IntCmd {
args := []interface{}{"TS.ADD", key, timestamp, value}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 1
func (cmdable) TSAddWithArgs
TSAddWithArgs - Adds one or more observations to a t-digest sketch. This function also allows for specifying additional options such as: Retention, ChunkSize, Encoding, DuplicatePolicy and Labels. For more information - https://redis.io/commands/ts.add/
func (c cmdable) TSAddWithArgs(ctx context.Context, key string, timestamp interface{}, value float64, options *TSOptions) *IntCmd {
args := []interface{}{"TS.ADD", key, timestamp, value}
if options != nil {
if options.Retention != 0 {
args = append(args, "RETENTION", options.Retention)
}
if options.ChunkSize != 0 {
args = append(args, "CHUNK_SIZE", options.ChunkSize)
}
if options.Encoding != "" {
args = append(args, "ENCODING", options.Encoding)
}
if options.DuplicatePolicy != "" {
args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy)
}
if options.Labels != nil {
args = append(args, "LABELS")
for label, value := range options.Labels {
args = append(args, label, value)
}
}
if options.IgnoreMaxTimeDiff != 0 || options.IgnoreMaxValDiff != 0 {
args = append(args, "IGNORE", options.IgnoreMaxTimeDiff, options.IgnoreMaxValDiff)
}
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 20
, Cyclomatic complexity: 10
func (cmdable) TSAlter
TSAlter - Alters an existing time-series key with additional options. This function allows for specifying additional options such as: Retention, ChunkSize and DuplicatePolicy. For more information - https://redis.io/commands/ts.alter/
func (c cmdable) TSAlter(ctx context.Context, key string, options *TSAlterOptions) *StatusCmd {
args := []interface{}{"TS.ALTER", key}
if options != nil {
if options.Retention != 0 {
args = append(args, "RETENTION", options.Retention)
}
if options.ChunkSize != 0 {
args = append(args, "CHUNK_SIZE", options.ChunkSize)
}
if options.DuplicatePolicy != "" {
args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy)
}
if options.Labels != nil {
args = append(args, "LABELS")
for label, value := range options.Labels {
args = append(args, label, value)
}
}
if options.IgnoreMaxTimeDiff != 0 || options.IgnoreMaxValDiff != 0 {
args = append(args, "IGNORE", options.IgnoreMaxTimeDiff, options.IgnoreMaxValDiff)
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 17
, Cyclomatic complexity: 9
func (cmdable) TSCreate
TSCreate - Creates a new time-series key. For more information - https://redis.io/commands/ts.create/
func (c cmdable) TSCreate(ctx context.Context, key string) *StatusCmd {
args := []interface{}{"TS.CREATE", key}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSCreateRule
TSCreateRule - Creates a compaction rule from sourceKey to destKey. For more information - https://redis.io/commands/ts.createrule/
func (c cmdable) TSCreateRule(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int) *StatusCmd {
args := []interface{}{"TS.CREATERULE", sourceKey, destKey, "AGGREGATION", aggregator.String(), bucketDuration}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSCreateRuleWithArgs
TSCreateRuleWithArgs - Creates a compaction rule from sourceKey to destKey with additional option. This function allows for specifying additional option such as: alignTimestamp. For more information - https://redis.io/commands/ts.createrule/
func (c cmdable) TSCreateRuleWithArgs(ctx context.Context, sourceKey string, destKey string, aggregator Aggregator, bucketDuration int, options *TSCreateRuleOptions) *StatusCmd {
args := []interface{}{"TS.CREATERULE", sourceKey, destKey, "AGGREGATION", aggregator.String(), bucketDuration}
if options != nil {
if options.alignTimestamp != 0 {
args = append(args, options.alignTimestamp)
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) TSCreateWithArgs
TSCreateWithArgs - Creates a new time-series key with additional options. This function allows for specifying additional options such as: Retention, ChunkSize, Encoding, DuplicatePolicy and Labels. For more information - https://redis.io/commands/ts.create/
func (c cmdable) TSCreateWithArgs(ctx context.Context, key string, options *TSOptions) *StatusCmd {
args := []interface{}{"TS.CREATE", key}
if options != nil {
if options.Retention != 0 {
args = append(args, "RETENTION", options.Retention)
}
if options.ChunkSize != 0 {
args = append(args, "CHUNK_SIZE", options.ChunkSize)
}
if options.Encoding != "" {
args = append(args, "ENCODING", options.Encoding)
}
if options.DuplicatePolicy != "" {
args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy)
}
if options.Labels != nil {
args = append(args, "LABELS")
for label, value := range options.Labels {
args = append(args, label, value)
}
}
if options.IgnoreMaxTimeDiff != 0 || options.IgnoreMaxValDiff != 0 {
args = append(args, "IGNORE", options.IgnoreMaxTimeDiff, options.IgnoreMaxValDiff)
}
}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 19
, Cyclomatic complexity: 10
func (cmdable) TSDecrBy
TSDecrBy - Decrements the value of a time-series key by the specified timestamp. For more information - https://redis.io/commands/ts.decrby/
func (c cmdable) TSDecrBy(ctx context.Context, Key string, timestamp float64) *IntCmd {
args := []interface{}{"TS.DECRBY", Key, timestamp}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSDecrByWithArgs
TSDecrByWithArgs - Decrements the value of a time-series key by the specified timestamp with additional options. This function allows for specifying additional options such as: Timestamp, Retention, ChunkSize, Uncompressed and Labels. For more information - https://redis.io/commands/ts.decrby/
func (c cmdable) TSDecrByWithArgs(ctx context.Context, key string, timestamp float64, options *TSIncrDecrOptions) *IntCmd {
args := []interface{}{"TS.DECRBY", key, timestamp}
if options != nil {
if options.Timestamp != 0 {
args = append(args, "TIMESTAMP", options.Timestamp)
}
if options.Retention != 0 {
args = append(args, "RETENTION", options.Retention)
}
if options.ChunkSize != 0 {
args = append(args, "CHUNK_SIZE", options.ChunkSize)
}
if options.Uncompressed {
args = append(args, "UNCOMPRESSED")
}
if options.DuplicatePolicy != "" {
args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy)
}
if options.Labels != nil {
args = append(args, "LABELS")
for label, value := range options.Labels {
args = append(args, label, value)
}
}
if options.IgnoreMaxTimeDiff != 0 || options.IgnoreMaxValDiff != 0 {
args = append(args, "IGNORE", options.IgnoreMaxTimeDiff, options.IgnoreMaxValDiff)
}
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 21
, Cyclomatic complexity: 11
func (cmdable) TSDel
TSDel - Deletes a range of samples from a time-series key. For more information - https://redis.io/commands/ts.del/
func (c cmdable) TSDel(ctx context.Context, Key string, fromTimestamp int, toTimestamp int) *IntCmd {
args := []interface{}{"TS.DEL", Key, fromTimestamp, toTimestamp}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSDeleteRule
TSDeleteRule - Deletes a compaction rule from sourceKey to destKey. For more information - https://redis.io/commands/ts.deleterule/
func (c cmdable) TSDeleteRule(ctx context.Context, sourceKey string, destKey string) *StatusCmd {
args := []interface{}{"TS.DELETERULE", sourceKey, destKey}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSGet
TSGet - Gets the last sample of a time-series key. For more information - https://redis.io/commands/ts.get/
func (c cmdable) TSGet(ctx context.Context, key string) *TSTimestampValueCmd {
args := []interface{}{"TS.GET", key}
cmd := newTSTimestampValueCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSGetWithArgs
TSGetWithArgs - Gets the last sample of a time-series key with additional option. This function allows for specifying additional option such as: Latest. For more information - https://redis.io/commands/ts.get/
func (c cmdable) TSGetWithArgs(ctx context.Context, key string, options *TSGetOptions) *TSTimestampValueCmd {
args := []interface{}{"TS.GET", key}
if options != nil {
if options.Latest {
args = append(args, "LATEST")
}
}
cmd := newTSTimestampValueCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) TSIncrBy
TSIncrBy - Increments the value of a time-series key by the specified timestamp. For more information - https://redis.io/commands/ts.incrby/
func (c cmdable) TSIncrBy(ctx context.Context, Key string, timestamp float64) *IntCmd {
args := []interface{}{"TS.INCRBY", Key, timestamp}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSIncrByWithArgs
TSIncrByWithArgs - Increments the value of a time-series key by the specified timestamp with additional options. This function allows for specifying additional options such as: Timestamp, Retention, ChunkSize, Uncompressed and Labels. For more information - https://redis.io/commands/ts.incrby/
func (c cmdable) TSIncrByWithArgs(ctx context.Context, key string, timestamp float64, options *TSIncrDecrOptions) *IntCmd {
args := []interface{}{"TS.INCRBY", key, timestamp}
if options != nil {
if options.Timestamp != 0 {
args = append(args, "TIMESTAMP", options.Timestamp)
}
if options.Retention != 0 {
args = append(args, "RETENTION", options.Retention)
}
if options.ChunkSize != 0 {
args = append(args, "CHUNK_SIZE", options.ChunkSize)
}
if options.Uncompressed {
args = append(args, "UNCOMPRESSED")
}
if options.DuplicatePolicy != "" {
args = append(args, "DUPLICATE_POLICY", options.DuplicatePolicy)
}
if options.Labels != nil {
args = append(args, "LABELS")
for label, value := range options.Labels {
args = append(args, label, value)
}
}
if options.IgnoreMaxTimeDiff != 0 || options.IgnoreMaxValDiff != 0 {
args = append(args, "IGNORE", options.IgnoreMaxTimeDiff, options.IgnoreMaxValDiff)
}
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 21
, Cyclomatic complexity: 11
func (cmdable) TSInfo
TSInfo - Returns information about a time-series key. For more information - https://redis.io/commands/ts.info/
func (c cmdable) TSInfo(ctx context.Context, key string) *MapStringInterfaceCmd {
args := []interface{}{"TS.INFO", key}
cmd := NewMapStringInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSInfoWithArgs
TSInfoWithArgs - Returns information about a time-series key with additional option. This function allows for specifying additional option such as: Debug. For more information - https://redis.io/commands/ts.info/
func (c cmdable) TSInfoWithArgs(ctx context.Context, key string, options *TSInfoOptions) *MapStringInterfaceCmd {
args := []interface{}{"TS.INFO", key}
if options != nil {
if options.Debug {
args = append(args, "DEBUG")
}
}
cmd := NewMapStringInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) TSMAdd
TSMAdd - Adds multiple samples to multiple time-series keys. It accepts a slice of 'ktv' slices, each containing exactly three elements: key, timestamp, and value. This struct must be provided for this command to work. For more information - https://redis.io/commands/ts.madd/
func (c cmdable) TSMAdd(ctx context.Context, ktvSlices [][]interface{}) *IntSliceCmd {
args := []interface{}{"TS.MADD"}
for _, ktv := range ktvSlices {
args = append(args, ktv...)
}
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 2
func (cmdable) TSMGet
TSMGet - Returns the last sample of multiple time-series keys. For more information - https://redis.io/commands/ts.mget/
func (c cmdable) TSMGet(ctx context.Context, filters []string) *MapStringSliceInterfaceCmd {
args := []interface{}{"TS.MGET", "FILTER"}
for _, f := range filters {
args = append(args, f)
}
cmd := NewMapStringSliceInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TSMGetWithArgs
TSMGetWithArgs - Returns the last sample of multiple time-series keys with additional options. This function allows for specifying additional options such as: Latest, WithLabels and SelectedLabels. For more information - https://redis.io/commands/ts.mget/
func (c cmdable) TSMGetWithArgs(ctx context.Context, filters []string, options *TSMGetOptions) *MapStringSliceInterfaceCmd {
args := []interface{}{"TS.MGET"}
if options != nil {
if options.Latest {
args = append(args, "LATEST")
}
if options.WithLabels {
args = append(args, "WITHLABELS")
}
if options.SelectedLabels != nil {
args = append(args, "SELECTED_LABELS")
args = append(args, options.SelectedLabels...)
}
}
args = append(args, "FILTER")
for _, f := range filters {
args = append(args, f)
}
cmd := NewMapStringSliceInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 13
, Cyclomatic complexity: 6
func (cmdable) TSMRange
TSMRange - Returns a range of samples from multiple time-series keys. For more information - https://redis.io/commands/ts.mrange/
func (c cmdable) TSMRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd {
args := []interface{}{"TS.MRANGE", fromTimestamp, toTimestamp, "FILTER"}
for _, f := range filterExpr {
args = append(args, f)
}
cmd := NewMapStringSliceInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TSMRangeWithArgs
TSMRangeWithArgs - Returns a range of samples from multiple time-series keys with additional options. This function allows for specifying additional options such as: Latest, FilterByTS, FilterByValue, WithLabels, SelectedLabels, Count, Align, Aggregator, BucketDuration, BucketTimestamp, Empty, GroupByLabel and Reducer. For more information - https://redis.io/commands/ts.mrange/
func (c cmdable) TSMRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRangeOptions) *MapStringSliceInterfaceCmd {
args := []interface{}{"TS.MRANGE", fromTimestamp, toTimestamp}
if options != nil {
if options.Latest {
args = append(args, "LATEST")
}
if options.FilterByTS != nil {
args = append(args, "FILTER_BY_TS")
for _, f := range options.FilterByTS {
args = append(args, f)
}
}
if options.FilterByValue != nil {
args = append(args, "FILTER_BY_VALUE")
for _, f := range options.FilterByValue {
args = append(args, f)
}
}
if options.WithLabels {
args = append(args, "WITHLABELS")
}
if options.SelectedLabels != nil {
args = append(args, "SELECTED_LABELS")
args = append(args, options.SelectedLabels...)
}
if options.Count != 0 {
args = append(args, "COUNT", options.Count)
}
if options.Align != nil {
args = append(args, "ALIGN", options.Align)
}
if options.Aggregator != 0 {
args = append(args, "AGGREGATION", options.Aggregator.String())
}
if options.BucketDuration != 0 {
args = append(args, options.BucketDuration)
}
if options.BucketTimestamp != nil {
args = append(args, "BUCKETTIMESTAMP", options.BucketTimestamp)
}
if options.Empty {
args = append(args, "EMPTY")
}
}
args = append(args, "FILTER")
for _, f := range filterExpr {
args = append(args, f)
}
if options != nil {
if options.GroupByLabel != nil {
args = append(args, "GROUPBY", options.GroupByLabel)
}
if options.Reducer != nil {
args = append(args, "REDUCE", options.Reducer)
}
}
cmd := NewMapStringSliceInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 41
, Cyclomatic complexity: 19
func (cmdable) TSMRevRange
TSMRevRange - Returns a range of samples from multiple time-series keys in reverse order. For more information - https://redis.io/commands/ts.mrevrange/
func (c cmdable) TSMRevRange(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string) *MapStringSliceInterfaceCmd {
args := []interface{}{"TS.MREVRANGE", fromTimestamp, toTimestamp, "FILTER"}
for _, f := range filterExpr {
args = append(args, f)
}
cmd := NewMapStringSliceInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TSMRevRangeWithArgs
TSMRevRangeWithArgs - Returns a range of samples from multiple time-series keys in reverse order with additional options. This function allows for specifying additional options such as: Latest, FilterByTS, FilterByValue, WithLabels, SelectedLabels, Count, Align, Aggregator, BucketDuration, BucketTimestamp, Empty, GroupByLabel and Reducer. For more information - https://redis.io/commands/ts.mrevrange/
func (c cmdable) TSMRevRangeWithArgs(ctx context.Context, fromTimestamp int, toTimestamp int, filterExpr []string, options *TSMRevRangeOptions) *MapStringSliceInterfaceCmd {
args := []interface{}{"TS.MREVRANGE", fromTimestamp, toTimestamp}
if options != nil {
if options.Latest {
args = append(args, "LATEST")
}
if options.FilterByTS != nil {
args = append(args, "FILTER_BY_TS")
for _, f := range options.FilterByTS {
args = append(args, f)
}
}
if options.FilterByValue != nil {
args = append(args, "FILTER_BY_VALUE")
for _, f := range options.FilterByValue {
args = append(args, f)
}
}
if options.WithLabels {
args = append(args, "WITHLABELS")
}
if options.SelectedLabels != nil {
args = append(args, "SELECTED_LABELS")
args = append(args, options.SelectedLabels...)
}
if options.Count != 0 {
args = append(args, "COUNT", options.Count)
}
if options.Align != nil {
args = append(args, "ALIGN", options.Align)
}
if options.Aggregator != 0 {
args = append(args, "AGGREGATION", options.Aggregator.String())
}
if options.BucketDuration != 0 {
args = append(args, options.BucketDuration)
}
if options.BucketTimestamp != nil {
args = append(args, "BUCKETTIMESTAMP", options.BucketTimestamp)
}
if options.Empty {
args = append(args, "EMPTY")
}
}
args = append(args, "FILTER")
for _, f := range filterExpr {
args = append(args, f)
}
if options != nil {
if options.GroupByLabel != nil {
args = append(args, "GROUPBY", options.GroupByLabel)
}
if options.Reducer != nil {
args = append(args, "REDUCE", options.Reducer)
}
}
cmd := NewMapStringSliceInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 41
, Cyclomatic complexity: 19
func (cmdable) TSQueryIndex
TSQueryIndex - Returns all the keys matching the filter expression. For more information - https://redis.io/commands/ts.queryindex/
func (c cmdable) TSQueryIndex(ctx context.Context, filterExpr []string) *StringSliceCmd {
args := []interface{}{"TS.QUERYINDEX"}
for _, f := range filterExpr {
args = append(args, f)
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) TSRange
TSRange - Returns a range of samples from a time-series key. For more information - https://redis.io/commands/ts.range/
func (c cmdable) TSRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd {
args := []interface{}{"TS.RANGE", key, fromTimestamp, toTimestamp}
cmd := newTSTimestampValueSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSRangeWithArgs
TSRangeWithArgs - Returns a range of samples from a time-series key with additional options. This function allows for specifying additional options such as: Latest, FilterByTS, FilterByValue, Count, Align, Aggregator, BucketDuration, BucketTimestamp and Empty. For more information - https://redis.io/commands/ts.range/
func (c cmdable) TSRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRangeOptions) *TSTimestampValueSliceCmd {
args := []interface{}{"TS.RANGE", key, fromTimestamp, toTimestamp}
if options != nil {
if options.Latest {
args = append(args, "LATEST")
}
if options.FilterByTS != nil {
args = append(args, "FILTER_BY_TS")
for _, f := range options.FilterByTS {
args = append(args, f)
}
}
if options.FilterByValue != nil {
args = append(args, "FILTER_BY_VALUE")
for _, f := range options.FilterByValue {
args = append(args, f)
}
}
if options.Count != 0 {
args = append(args, "COUNT", options.Count)
}
if options.Align != nil {
args = append(args, "ALIGN", options.Align)
}
if options.Aggregator != 0 {
args = append(args, "AGGREGATION", options.Aggregator.String())
}
if options.BucketDuration != 0 {
args = append(args, options.BucketDuration)
}
if options.BucketTimestamp != nil {
args = append(args, "BUCKETTIMESTAMP", options.BucketTimestamp)
}
if options.Empty {
args = append(args, "EMPTY")
}
}
cmd := newTSTimestampValueSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 28
, Cyclomatic complexity: 13
func (cmdable) TSRevRange
TSRevRange - Returns a range of samples from a time-series key in reverse order. For more information - https://redis.io/commands/ts.revrange/
func (c cmdable) TSRevRange(ctx context.Context, key string, fromTimestamp int, toTimestamp int) *TSTimestampValueSliceCmd {
args := []interface{}{"TS.REVRANGE", key, fromTimestamp, toTimestamp}
cmd := newTSTimestampValueSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TSRevRangeWithArgs
TSRevRangeWithArgs - Returns a range of samples from a time-series key in reverse order with additional options. This function allows for specifying additional options such as: Latest, FilterByTS, FilterByValue, Count, Align, Aggregator, BucketDuration, BucketTimestamp and Empty. For more information - https://redis.io/commands/ts.revrange/
func (c cmdable) TSRevRangeWithArgs(ctx context.Context, key string, fromTimestamp int, toTimestamp int, options *TSRevRangeOptions) *TSTimestampValueSliceCmd {
args := []interface{}{"TS.REVRANGE", key, fromTimestamp, toTimestamp}
if options != nil {
if options.Latest {
args = append(args, "LATEST")
}
if options.FilterByTS != nil {
args = append(args, "FILTER_BY_TS")
for _, f := range options.FilterByTS {
args = append(args, f)
}
}
if options.FilterByValue != nil {
args = append(args, "FILTER_BY_VALUE")
for _, f := range options.FilterByValue {
args = append(args, f)
}
}
if options.Count != 0 {
args = append(args, "COUNT", options.Count)
}
if options.Align != nil {
args = append(args, "ALIGN", options.Align)
}
if options.Aggregator != 0 {
args = append(args, "AGGREGATION", options.Aggregator.String())
}
if options.BucketDuration != 0 {
args = append(args, options.BucketDuration)
}
if options.BucketTimestamp != nil {
args = append(args, "BUCKETTIMESTAMP", options.BucketTimestamp)
}
if options.Empty {
args = append(args, "EMPTY")
}
}
cmd := newTSTimestampValueSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 28
, Cyclomatic complexity: 13
func (cmdable) TTL
func (c cmdable) TTL(ctx context.Context, key string) *DurationCmd {
cmd := NewDurationCmd(ctx, time.Second, "ttl", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) TopKAdd
TopKAdd adds one or more elements to a Top-K filter. Returns an array of strings representing the items that were removed from the filter, if any. For more information - https://redis.io/commands/topk.add/
func (c cmdable) TopKAdd(ctx context.Context, key string, elements ...interface{}) *StringSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TOPK.ADD"
args[1] = key
args = appendArgs(args, elements)
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKCount
TopKCount returns an estimate of the number of times an item may be in a Top-K filter. For more information - https://redis.io/commands/topk.count/
func (c cmdable) TopKCount(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TOPK.COUNT"
args[1] = key
args = appendArgs(args, elements)
cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKIncrBy
TopKIncrBy increases the count of one or more items in a Top-K filter. For more information - https://redis.io/commands/topk.incrby/
func (c cmdable) TopKIncrBy(ctx context.Context, key string, elements ...interface{}) *StringSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TOPK.INCRBY"
args[1] = key
args = appendArgs(args, elements)
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKInfo
TopKInfo returns information about a Top-K filter. For more information - https://redis.io/commands/topk.info/
func (c cmdable) TopKInfo(ctx context.Context, key string) *TopKInfoCmd {
args := []interface{}{"TOPK.INFO", key}
cmd := NewTopKInfoCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKList
TopKList returns all items in Top-K list. For more information - https://redis.io/commands/topk.list/
func (c cmdable) TopKList(ctx context.Context, key string) *StringSliceCmd {
args := []interface{}{"TOPK.LIST", key}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKListWithCount
TopKListWithCount returns all items in Top-K list with their respective count. For more information - https://redis.io/commands/topk.list/
func (c cmdable) TopKListWithCount(ctx context.Context, key string) *MapStringIntCmd {
args := []interface{}{"TOPK.LIST", key, "WITHCOUNT"}
cmd := NewMapStringIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKQuery
TopKQuery check if multiple elements exist in a Top-K filter. Returns an array of booleans indicating whether each element exists in the filter or not. For more information - https://redis.io/commands/topk.query/
func (c cmdable) TopKQuery(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd {
args := make([]interface{}, 2, 2+len(elements))
args[0] = "TOPK.QUERY"
args[1] = key
args = appendArgs(args, elements)
cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKReserve
TopKReserve creates an empty Top-K filter with the specified number of top items to keep. For more information - https://redis.io/commands/topk.reserve/
func (c cmdable) TopKReserve(ctx context.Context, key string, k int64) *StatusCmd {
args := []interface{}{"TOPK.RESERVE", key, k}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) TopKReserveWithOptions
TopKReserveWithOptions creates an empty Top-K filter with the specified number of top items to keep and additional options. This function allows for specifying additional options such as width, depth and decay. For more information - https://redis.io/commands/topk.reserve/
func (c cmdable) TopKReserveWithOptions(ctx context.Context, key string, k int64, width, depth int64, decay float64) *StatusCmd {
args := []interface{}{"TOPK.RESERVE", key, k, width, depth, decay}
cmd := NewStatusCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) Touch
func (c cmdable) Touch(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, len(keys)+1)
args[0] = "touch"
for i, key := range keys {
args[i+1] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) Type
func (c cmdable) Type(ctx context.Context, key string) *StatusCmd {
cmd := NewStatusCmd(ctx, "type", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) Unlink
func (c cmdable) Unlink(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, 1+len(keys))
args[0] = "unlink"
for i, key := range keys {
args[1+i] = key
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) Wait
func (c cmdable) Wait(ctx context.Context, numSlaves int, timeout time.Duration) *IntCmd {
cmd := NewIntCmd(ctx, "wait", numSlaves, int(timeout/time.Millisecond))
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) WaitAOF
func (c cmdable) WaitAOF(ctx context.Context, numLocal, numSlaves int, timeout time.Duration) *IntCmd {
cmd := NewIntCmd(ctx, "waitAOF", numLocal, numSlaves, int(timeout/time.Millisecond))
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XAck
func (c cmdable) XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd {
args := []interface{}{"xack", stream, group}
for _, id := range ids {
args = append(args, id)
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) XAdd
func (c cmdable) XAdd(ctx context.Context, a *XAddArgs) *StringCmd {
args := make([]interface{}, 0, 11)
args = append(args, "xadd", a.Stream)
if a.NoMkStream {
args = append(args, "nomkstream")
}
switch {
case a.MaxLen > 0:
if a.Approx {
args = append(args, "maxlen", "~", a.MaxLen)
} else {
args = append(args, "maxlen", a.MaxLen)
}
case a.MinID != "":
if a.Approx {
args = append(args, "minid", "~", a.MinID)
} else {
args = append(args, "minid", a.MinID)
}
}
if a.Limit > 0 {
args = append(args, "limit", a.Limit)
}
if a.ID != "" {
args = append(args, a.ID)
} else {
args = append(args, "*")
}
args = appendArg(args, a.Values)
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 21
, Cyclomatic complexity: 9
func (cmdable) XAutoClaim
func (c cmdable) XAutoClaim(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimCmd {
args := xAutoClaimArgs(ctx, a)
cmd := NewXAutoClaimCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XAutoClaimJustID
func (c cmdable) XAutoClaimJustID(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimJustIDCmd {
args := xAutoClaimArgs(ctx, a)
args = append(args, "justid")
cmd := NewXAutoClaimJustIDCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XClaim
func (c cmdable) XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd {
args := xClaimArgs(a)
cmd := NewXMessageSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XClaimJustID
func (c cmdable) XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd {
args := xClaimArgs(a)
args = append(args, "justid")
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XDel
func (c cmdable) XDel(ctx context.Context, stream string, ids ...string) *IntCmd {
args := []interface{}{"xdel", stream}
for _, id := range ids {
args = append(args, id)
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 2
func (cmdable) XGroupCreate
func (c cmdable) XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd {
cmd := NewStatusCmd(ctx, "xgroup", "create", stream, group, start)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XGroupCreateConsumer
func (c cmdable) XGroupCreateConsumer(ctx context.Context, stream, group, consumer string) *IntCmd {
cmd := NewIntCmd(ctx, "xgroup", "createconsumer", stream, group, consumer)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XGroupCreateMkStream
func (c cmdable) XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd {
cmd := NewStatusCmd(ctx, "xgroup", "create", stream, group, start, "mkstream")
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XGroupDelConsumer
func (c cmdable) XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd {
cmd := NewIntCmd(ctx, "xgroup", "delconsumer", stream, group, consumer)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XGroupDestroy
func (c cmdable) XGroupDestroy(ctx context.Context, stream, group string) *IntCmd {
cmd := NewIntCmd(ctx, "xgroup", "destroy", stream, group)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XGroupSetID
func (c cmdable) XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd {
cmd := NewStatusCmd(ctx, "xgroup", "setid", stream, group, start)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XInfoConsumers
func (c cmdable) XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd {
cmd := NewXInfoConsumersCmd(ctx, key, group)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XInfoGroups
func (c cmdable) XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd {
cmd := NewXInfoGroupsCmd(ctx, key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XInfoStream
func (c cmdable) XInfoStream(ctx context.Context, key string) *XInfoStreamCmd {
cmd := NewXInfoStreamCmd(ctx, key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XInfoStreamFull
XInfoStreamFull XINFO STREAM FULL [COUNT count] redis-server >= 6.0.
func (c cmdable) XInfoStreamFull(ctx context.Context, key string, count int) *XInfoStreamFullCmd {
args := make([]interface{}, 0, 6)
args = append(args, "xinfo", "stream", key, "full")
if count > 0 {
args = append(args, "count", count)
}
cmd := NewXInfoStreamFullCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 3
, Cyclomatic complexity: 2
func (cmdable) XLen
func (c cmdable) XLen(ctx context.Context, stream string) *IntCmd {
cmd := NewIntCmd(ctx, "xlen", stream)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XPending
func (c cmdable) XPending(ctx context.Context, stream, group string) *XPendingCmd {
cmd := NewXPendingCmd(ctx, "xpending", stream, group)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XPendingExt
func (c cmdable) XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd {
args := make([]interface{}, 0, 9)
args = append(args, "xpending", a.Stream, a.Group)
if a.Idle != 0 {
args = append(args, "idle", formatMs(ctx, a.Idle))
}
args = append(args, a.Start, a.End, a.Count)
if a.Consumer != "" {
args = append(args, a.Consumer)
}
cmd := NewXPendingExtCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 5
, Cyclomatic complexity: 3
func (cmdable) XRange
func (c cmdable) XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd {
cmd := NewXMessageSliceCmd(ctx, "xrange", stream, start, stop)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XRangeN
func (c cmdable) XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd {
cmd := NewXMessageSliceCmd(ctx, "xrange", stream, start, stop, "count", count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XRead
func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd {
args := make([]interface{}, 0, 2*len(a.Streams)+6)
args = append(args, "xread")
keyPos := int8(1)
if a.Count > 0 {
args = append(args, "count")
args = append(args, a.Count)
keyPos += 2
}
if a.Block >= 0 {
args = append(args, "block")
args = append(args, int64(a.Block/time.Millisecond))
keyPos += 2
}
args = append(args, "streams")
keyPos++
for _, s := range a.Streams {
args = append(args, s)
}
if a.ID != "" {
for range a.Streams {
args = append(args, a.ID)
}
}
cmd := NewXStreamSliceCmd(ctx, args...)
if a.Block >= 0 {
cmd.setReadTimeout(a.Block)
}
cmd.SetFirstKeyPos(keyPos)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 15
, Cyclomatic complexity: 7
func (cmdable) XReadGroup
func (c cmdable) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd {
args := make([]interface{}, 0, 10+len(a.Streams))
args = append(args, "xreadgroup", "group", a.Group, a.Consumer)
keyPos := int8(4)
if a.Count > 0 {
args = append(args, "count", a.Count)
keyPos += 2
}
if a.Block >= 0 {
args = append(args, "block", int64(a.Block/time.Millisecond))
keyPos += 2
}
if a.NoAck {
args = append(args, "noack")
keyPos++
}
args = append(args, "streams")
keyPos++
for _, s := range a.Streams {
args = append(args, s)
}
cmd := NewXStreamSliceCmd(ctx, args...)
if a.Block >= 0 {
cmd.setReadTimeout(a.Block)
}
cmd.SetFirstKeyPos(keyPos)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 12
, Cyclomatic complexity: 6
func (cmdable) XReadStreams
func (c cmdable) XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd {
return c.XRead(ctx, &XReadArgs{
Streams: streams,
Block: -1,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) XRevRange
func (c cmdable) XRevRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd {
cmd := NewXMessageSliceCmd(ctx, "xrevrange", stream, start, stop)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XRevRangeN
func (c cmdable) XRevRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd {
cmd := NewXMessageSliceCmd(ctx, "xrevrange", stream, start, stop, "count", count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XTrimMaxLen
XTrimMaxLen No ~
rules are used, limit
cannot be used.
cmd: XTRIM key MAXLEN maxLen
func (c cmdable) XTrimMaxLen(ctx context.Context, key string, maxLen int64) *IntCmd {
return c.xTrim(ctx, key, "maxlen", false, maxLen, 0)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XTrimMaxLenApprox
func (c cmdable) XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) *IntCmd {
return c.xTrim(ctx, key, "maxlen", true, maxLen, limit)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XTrimMinID
func (c cmdable) XTrimMinID(ctx context.Context, key string, minID string) *IntCmd {
return c.xTrim(ctx, key, "minid", false, minID, 0)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) XTrimMinIDApprox
func (c cmdable) XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd {
return c.xTrim(ctx, key, "minid", true, minID, limit)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZAdd
ZAdd Redis ZADD key score member [score member ...]
command.
func (c cmdable) ZAdd(ctx context.Context, key string, members ...Z) *IntCmd {
return c.ZAddArgs(ctx, key, ZAddArgs{
Members: members,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZAddArgs
func (c cmdable) ZAddArgs(ctx context.Context, key string, args ZAddArgs) *IntCmd {
cmd := NewIntCmd(ctx, c.zAddArgs(key, args, false)...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZAddArgsIncr
func (c cmdable) ZAddArgsIncr(ctx context.Context, key string, args ZAddArgs) *FloatCmd {
cmd := NewFloatCmd(ctx, c.zAddArgs(key, args, true)...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZAddGT
ZAddGT Redis ZADD key GT score member [score member ...]
command.
func (c cmdable) ZAddGT(ctx context.Context, key string, members ...Z) *IntCmd {
return c.ZAddArgs(ctx, key, ZAddArgs{
GT: true,
Members: members,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZAddLT
ZAddLT Redis ZADD key LT score member [score member ...]
command.
func (c cmdable) ZAddLT(ctx context.Context, key string, members ...Z) *IntCmd {
return c.ZAddArgs(ctx, key, ZAddArgs{
LT: true,
Members: members,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZAddNX
ZAddNX Redis ZADD key NX score member [score member ...]
command.
func (c cmdable) ZAddNX(ctx context.Context, key string, members ...Z) *IntCmd {
return c.ZAddArgs(ctx, key, ZAddArgs{
NX: true,
Members: members,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZAddXX
ZAddXX Redis ZADD key XX score member [score member ...]
command.
func (c cmdable) ZAddXX(ctx context.Context, key string, members ...Z) *IntCmd {
return c.ZAddArgs(ctx, key, ZAddArgs{
XX: true,
Members: members,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZCard
func (c cmdable) ZCard(ctx context.Context, key string) *IntCmd {
cmd := NewIntCmd(ctx, "zcard", key)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZCount
func (c cmdable) ZCount(ctx context.Context, key, min, max string) *IntCmd {
cmd := NewIntCmd(ctx, "zcount", key, min, max)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZDiff
ZDiff redis-server version >= 6.2.0.
func (c cmdable) ZDiff(ctx context.Context, keys ...string) *StringSliceCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "zdiff"
args[1] = len(keys)
for i, key := range keys {
args[i+2] = key
}
cmd := NewStringSliceCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ZDiffStore
ZDiffStore redis-server version >=6.2.0.
func (c cmdable) ZDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd {
args := make([]interface{}, 0, 3+len(keys))
args = append(args, "zdiffstore", destination, len(keys))
for _, key := range keys {
args = append(args, key)
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ZDiffWithScores
ZDiffWithScores redis-server version >= 6.2.0.
func (c cmdable) ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd {
args := make([]interface{}, 3+len(keys))
args[0] = "zdiff"
args[1] = len(keys)
for i, key := range keys {
args[i+2] = key
}
args[len(keys)+2] = "withscores"
cmd := NewZSliceCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ZIncrBy
func (c cmdable) ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd {
cmd := NewFloatCmd(ctx, "zincrby", key, increment, member)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZInter
func (c cmdable) ZInter(ctx context.Context, store *ZStore) *StringSliceCmd {
args := make([]interface{}, 0, 2+store.len())
args = append(args, "zinter", len(store.Keys))
args = store.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZInterCard
func (c cmdable) ZInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd {
args := make([]interface{}, 4+len(keys))
args[0] = "zintercard"
numkeys := int64(0)
for i, key := range keys {
args[2+i] = key
numkeys++
}
args[1] = numkeys
args[2+numkeys] = "limit"
args[3+numkeys] = limit
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ZInterStore
func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd {
args := make([]interface{}, 0, 3+store.len())
args = append(args, "zinterstore", destination, len(store.Keys))
args = store.appendArgs(args)
cmd := NewIntCmd(ctx, args...)
cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZInterWithScores
func (c cmdable) ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd {
args := make([]interface{}, 0, 3+store.len())
args = append(args, "zinter", len(store.Keys))
args = store.appendArgs(args)
args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZLexCount
func (c cmdable) ZLexCount(ctx context.Context, key, min, max string) *IntCmd {
cmd := NewIntCmd(ctx, "zlexcount", key, min, max)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZMPop
ZMPop Pops one or more elements with the highest or lowest score from the first non-empty sorted set key from the list of provided key names. direction: "max" (highest score) or "min" (lowest score), count: > 0 example: client.ZMPop(ctx, "max", 5, "set1", "set2")
func (c cmdable) ZMPop(ctx context.Context, order string, count int64, keys ...string) *ZSliceWithKeyCmd {
args := make([]interface{}, 2+len(keys), 5+len(keys))
args[0] = "zmpop"
args[1] = len(keys)
for i, key := range keys {
args[2+i] = key
}
args = append(args, strings.ToLower(order), "count", count)
cmd := NewZSliceWithKeyCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ZMScore
func (c cmdable) ZMScore(ctx context.Context, key string, members ...string) *FloatSliceCmd {
args := make([]interface{}, 2+len(members))
args[0] = "zmscore"
args[1] = key
for i, member := range members {
args[2+i] = member
}
cmd := NewFloatSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 2
func (cmdable) ZPopMax
func (c cmdable) ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd {
args := []interface{}{
"zpopmax",
key,
}
switch len(count) {
case 0:
break
case 1:
args = append(args, count[0])
default:
panic("too many arguments")
}
cmd := NewZSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 4
func (cmdable) ZPopMin
func (c cmdable) ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd {
args := []interface{}{
"zpopmin",
key,
}
switch len(count) {
case 0:
break
case 1:
args = append(args, count[0])
default:
panic("too many arguments")
}
cmd := NewZSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 4
func (cmdable) ZRandMember
ZRandMember redis-server version >= 6.2.0.
func (c cmdable) ZRandMember(ctx context.Context, key string, count int) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "zrandmember", key, count)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRandMemberWithScores
ZRandMemberWithScores redis-server version >= 6.2.0.
func (c cmdable) ZRandMemberWithScores(ctx context.Context, key string, count int) *ZSliceCmd {
cmd := NewZSliceCmd(ctx, "zrandmember", key, count, "withscores")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRange
func (c cmdable) ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd {
return c.ZRangeArgs(ctx, ZRangeArgs{
Key: key,
Start: start,
Stop: stop,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZRangeArgs
func (c cmdable) ZRangeArgs(ctx context.Context, z ZRangeArgs) *StringSliceCmd {
args := make([]interface{}, 0, 9)
args = append(args, "zrange")
args = z.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZRangeArgsWithScores
func (c cmdable) ZRangeArgsWithScores(ctx context.Context, z ZRangeArgs) *ZSliceCmd {
args := make([]interface{}, 0, 10)
args = append(args, "zrange")
args = z.appendArgs(args)
args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZRangeByLex
func (c cmdable) ZRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd {
return c.zRangeBy(ctx, "zrangebylex", key, opt, false)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRangeByScore
func (c cmdable) ZRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd {
return c.zRangeBy(ctx, "zrangebyscore", key, opt, false)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRangeByScoreWithScores
func (c cmdable) ZRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd {
args := []interface{}{"zrangebyscore", key, opt.Min, opt.Max, "withscores"}
if opt.Offset != 0 || opt.Count != 0 {
args = append(
args,
"limit",
opt.Offset,
opt.Count,
)
}
cmd := NewZSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func (cmdable) ZRangeStore
func (c cmdable) ZRangeStore(ctx context.Context, dst string, z ZRangeArgs) *IntCmd {
args := make([]interface{}, 0, 10)
args = append(args, "zrangestore", dst)
args = z.appendArgs(args)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZRangeWithScores
func (c cmdable) ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd {
return c.ZRangeArgsWithScores(ctx, ZRangeArgs{
Key: key,
Start: start,
Stop: stop,
})
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZRank
func (c cmdable) ZRank(ctx context.Context, key, member string) *IntCmd {
cmd := NewIntCmd(ctx, "zrank", key, member)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRankWithScore
ZRankWithScore according to the Redis documentation, if member does not exist in the sorted set or key does not exist, it will return a redis.Nil error.
func (c cmdable) ZRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd {
cmd := NewRankWithScoreCmd(ctx, "zrank", key, member, "withscore")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRem
func (c cmdable) ZRem(ctx context.Context, key string, members ...interface{}) *IntCmd {
args := make([]interface{}, 2, 2+len(members))
args[0] = "zrem"
args[1] = key
args = appendArgs(args, members)
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 2
, Cyclomatic complexity: 1
func (cmdable) ZRemRangeByLex
func (c cmdable) ZRemRangeByLex(ctx context.Context, key, min, max string) *IntCmd {
cmd := NewIntCmd(ctx, "zremrangebylex", key, min, max)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRemRangeByRank
func (c cmdable) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd {
cmd := NewIntCmd(
ctx,
"zremrangebyrank",
key,
start,
stop,
)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRemRangeByScore
func (c cmdable) ZRemRangeByScore(ctx context.Context, key, min, max string) *IntCmd {
cmd := NewIntCmd(ctx, "zremrangebyscore", key, min, max)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRevRange
func (c cmdable) ZRevRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "zrevrange", key, start, stop)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRevRangeByLex
func (c cmdable) ZRevRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd {
return c.zRevRangeBy(ctx, "zrevrangebylex", key, opt)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRevRangeByScore
func (c cmdable) ZRevRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd {
return c.zRevRangeBy(ctx, "zrevrangebyscore", key, opt)
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRevRangeByScoreWithScores
func (c cmdable) ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd {
args := []interface{}{"zrevrangebyscore", key, opt.Max, opt.Min, "withscores"}
if opt.Offset != 0 || opt.Count != 0 {
args = append(
args,
"limit",
opt.Offset,
opt.Count,
)
}
cmd := NewZSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 4
, Cyclomatic complexity: 3
func (cmdable) ZRevRangeWithScores
ZRevRangeWithScores according to the Redis documentation, if member does not exist in the sorted set or key does not exist, it will return a redis.Nil error.
func (c cmdable) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd {
cmd := NewZSliceCmd(ctx, "zrevrange", key, start, stop, "withscores")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRevRank
func (c cmdable) ZRevRank(ctx context.Context, key, member string) *IntCmd {
cmd := NewIntCmd(ctx, "zrevrank", key, member)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZRevRankWithScore
func (c cmdable) ZRevRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd {
cmd := NewRankWithScoreCmd(ctx, "zrevrank", key, member, "withscore")
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZScan
func (c cmdable) ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd {
args := []interface{}{"zscan", key, cursor}
if match != "" {
args = append(args, "match", match)
}
if count > 0 {
args = append(args, "count", count)
}
cmd := NewScanCmd(ctx, c, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (cmdable) ZScore
func (c cmdable) ZScore(ctx context.Context, key, member string) *FloatCmd {
cmd := NewFloatCmd(ctx, "zscore", key, member)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (cmdable) ZUnion
func (c cmdable) ZUnion(ctx context.Context, store ZStore) *StringSliceCmd {
args := make([]interface{}, 0, 2+store.len())
args = append(args, "zunion", len(store.Keys))
args = store.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZUnionStore
func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd {
args := make([]interface{}, 0, 3+store.len())
args = append(args, "zunionstore", dest, len(store.Keys))
args = store.appendArgs(args)
cmd := NewIntCmd(ctx, args...)
cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (cmdable) ZUnionWithScores
func (c cmdable) ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd {
args := make([]interface{}, 0, 3+store.len())
args = append(args, "zunion", len(store.Keys))
args = store.appendArgs(args)
args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 1
, Cyclomatic complexity: 1
func (statefulCmdable) Auth
func (c statefulCmdable) Auth(ctx context.Context, password string) *StatusCmd {
cmd := NewStatusCmd(ctx, "auth", password)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (statefulCmdable) AuthACL
AuthACL Perform an AUTH command, using the given user and pass. Should be used to authenticate the current connection with one of the connections defined in the ACL list when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
func (c statefulCmdable) AuthACL(ctx context.Context, username, password string) *StatusCmd {
cmd := NewStatusCmd(ctx, "auth", username, password)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (statefulCmdable) ClientSetInfo
ClientSetInfo sends a CLIENT SETINFO command with the provided info.
func (c statefulCmdable) ClientSetInfo(ctx context.Context, info LibraryInfo) *StatusCmd {
err := info.Validate()
if err != nil {
panic(err.Error())
}
var cmd *StatusCmd
if info.LibName != nil {
libName := fmt.Sprintf("go-redis(%s,%s)", *info.LibName, internal.ReplaceSpaces(runtime.Version()))
cmd = NewStatusCmd(ctx, "client", "setinfo", "LIB-NAME", libName)
} else {
cmd = NewStatusCmd(ctx, "client", "setinfo", "LIB-VER", *info.LibVer)
}
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 6
, Cyclomatic complexity: 3
func (statefulCmdable) ClientSetName
ClientSetName assigns a name to the connection.
func (c statefulCmdable) ClientSetName(ctx context.Context, name string) *BoolCmd {
cmd := NewBoolCmd(ctx, "client", "setname", name)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (statefulCmdable) Hello
Hello Set the resp protocol used.
func (c statefulCmdable) Hello(ctx context.Context,
ver int, username, password, clientName string,
) *MapStringInterfaceCmd {
args := make([]interface{}, 0, 7)
args = append(args, "hello", ver)
if password != "" {
if username != "" {
args = append(args, "auth", username, password)
} else {
args = append(args, "auth", "default", password)
}
}
if clientName != "" {
args = append(args, "setname", clientName)
}
cmd := NewMapStringInterfaceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 9
, Cyclomatic complexity: 4
func (statefulCmdable) Select
func (c statefulCmdable) Select(ctx context.Context, index int) *StatusCmd {
cmd := NewStatusCmd(ctx, "select", index)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
func (statefulCmdable) SwapDB
func (c statefulCmdable) SwapDB(ctx context.Context, index1, index2 int) *StatusCmd {
cmd := NewStatusCmd(ctx, "swapdb", index1, index2)
_ = c(ctx, cmd)
return cmd
}
Cognitive complexity: 0
, Cyclomatic complexity: 1
Private functions
func appendArg
appendArg (dst []interface{}, arg interface{}) []interface{}
References: encoding.BinaryMarshaler, net.IP, reflect.Ptr, reflect.Struct, reflect.ValueOf, time.Duration, time.Time.
func appendArgs
appendArgs (dst,src []interface{}) []interface{}
func appendIfNotExists
appendIfNotExists (ss []string, es ...string) []string
func appendStructField
appendStructField appends the field and value held by the structure v to dst, and returns the appended dst.
appendStructField (dst []interface{}, v reflect.Value) []interface{}
References: strings.Cut.
func appendUniqueNode
appendUniqueNode (nodes []*clusterNode, node *clusterNode) []*clusterNode
func cmdFirstKeyPos
cmdFirstKeyPos (cmd Cmder) int
func cmdString
cmdString (cmd Cmder, val interface{}) string
References: util.BytesToString.
func cmdsFirstErr
cmdsFirstErr (cmds []Cmder) error
func contains
contains (slice []string, str string) bool
func fcallArgs
fcallArgs (command string, function string, keys []string, args ...interface{}) []interface{}
func formatMs
formatMs (ctx context.Context, dur time.Duration) int64
References: time.Millisecond.
func formatSec
formatSec (ctx context.Context, dur time.Duration) int64
References: time.Second.
func geoLocationArgs
geoLocationArgs (q *GeoRadiusQuery, args ...interface{}) []interface{}
func geoSearchArgs
geoSearchArgs (q *GeoSearchQuery, args []interface{}) []interface{}
func geoSearchLocationArgs
geoSearchLocationArgs (q *GeoSearchLocationQuery, args []interface{}) []interface{}
func getHostPortWithDefaults
getHostPortWithDefaults is a helper function that splits the url into a host and a port. If the host is missing, it defaults to localhost and if the port is missing, it defaults to 6379.
getHostPortWithDefaults (u *url.URL) (string, string)
References: net.SplitHostPort.
func getUserPassword
getUserPassword (u *url.URL) (string, string)
func isBadConn
isBadConn (err error, allowTimeout bool, addr string) bool
References: context.Canceled, context.DeadlineExceeded, net.Error.
func isEmptyValue
isEmptyValue (v reflect.Value) bool
References: reflect.Array, reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int8, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice, reflect.String, reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint8, reflect.Uintptr.
func isLoadingError
isLoadingError (err error) bool
References: strings.HasPrefix.
func isLoopback
isLoopback (host string) bool
References: net.ParseIP.
func isMovedError
isMovedError (err error) (bool, bool, string)
References: strings.HasPrefix, strings.LastIndex.
func isMovedSameConnAddr
isMovedSameConnAddr (err error, addr string) bool
References: strings.HasPrefix, strings.HasSuffix.
func isReadOnlyError
isReadOnlyError (err error) bool
References: strings.HasPrefix.
func isRedisError
isRedisError (err error) bool
References: proto.RedisError.
func mapKeys
mapKeys (m map[string]struct{}) []string
func masterReplicaDialer
masterReplicaDialer (failover *sentinelFailover) func(ctx context.Context, network, addr string) (net.Conn, error)
References: context.Context, net.Conn, net.Dialer, time.Minute, tls.DialWithDialer.
func newChannel
newChannel (pubSub *PubSub, opts ...ChannelOption) *channel
References: time.Minute, time.Second.
func newClusterNode
newClusterNode (clOpt *ClusterOptions, addr string) *clusterNode
References: math.MaxUint32.
func newClusterNodes
newClusterNodes (opt *ClusterOptions) *clusterNodes
func newClusterState
newClusterState (nodes *clusterNodes, slots []ClusterSlot, origin string) (*clusterState, error)
References: net.SplitHostPort, sort.Sort, time.AfterFunc, time.Minute, time.Now.
func newClusterStateHolder
newClusterStateHolder (fn func(ctx context.Context) (*clusterState, error)) *clusterStateHolder
func newCmdsInfoCache
newCmdsInfoCache (fn func(ctx context.Context) (map[string]*CommandInfo, error)) *cmdsInfoCache
func newCmdsMap
newCmdsMap () *cmdsMap
func newConnPool
newConnPool (opt *Options, dialer func(ctx context.Context, network, addr string) (net.Conn, error)) *pool.ConnPool
References: context.Context, net.Conn, pool.NewConnPool, pool.Options.
func newFTInfoCmd
newFTInfoCmd (ctx context.Context, args ...interface{}) *FTInfoCmd
func newFTSearchCmd
newFTSearchCmd (ctx context.Context, options *FTSearchOptions, args ...interface{}) *FTSearchCmd
func newFTSpellCheckCmd
newFTSpellCheckCmd (ctx context.Context, args ...interface{}) *FTSpellCheckCmd
func newJSONCmd
newJSONCmd (ctx context.Context, args ...interface{}) *JSONCmd
func newMonitorCmd
newMonitorCmd (ctx context.Context, ch chan string) *MonitorCmd
References: sync.Mutex.
func newRendezvous
newRendezvous (shards []string) ConsistentHash
func newRingShard
newRingShard (opt *RingOptions, addr string) *ringShard
func newRingSharding
newRingSharding (opt *RingOptions) *ringSharding
func newScanDumpCmd
newScanDumpCmd (ctx context.Context, args ...interface{}) *ScanDumpCmd
func newTSTimestampValueCmd
newTSTimestampValueCmd (ctx context.Context, args ...interface{}) *TSTimestampValueCmd
func newTSTimestampValueSliceCmd
newTSTimestampValueSliceCmd (ctx context.Context, args ...interface{}) *TSTimestampValueSliceCmd
func omitEmpty
omitEmpty (opt string) bool
References: strings.Cut.
func parseClientInfo
fmt.Sscanf() cannot handle null values
parseClientInfo (txt string) (*ClientInfo, error)
References: fmt.Errorf, strconv.Atoi, strconv.ParseInt, strings.Split, time.Duration, time.Second.
func parseFTInfo
parseFTInfo (data map[string]interface{}) (FTInfoResult, error)
func parseFTSearch
parseFTSearch (data []interface{}, noContent,withScores,withPayloads,withSortKeys bool) (FTSearchResult, error)
References: fmt.Errorf, strconv.ParseFloat.
func parseFTSpellCheck
parseFTSpellCheck (data []interface{}) ([]SpellCheckResult, error)
References: fmt.Errorf, strconv.ParseFloat.
func parseReplicaAddrs
parseReplicaAddrs (addrs []map[string]string, keepDisconnected bool) []string
References: net.JoinHostPort, strings.Split.
func readStreamGroups
readStreamGroups (rd *proto.Reader) ([]XInfoStreamGroup, error)
References: fmt.Errorf.
func readXInfoStreamConsumers
readXInfoStreamConsumers (rd *proto.Reader) ([]XInfoStreamConsumer, error)
References: fmt.Errorf, time.Millisecond, time.Unix, time.UnixMilli.
func readXInfoStreamGroupPending
readXInfoStreamGroupPending (rd *proto.Reader) ([]XInfoStreamGroupPending, error)
References: time.Millisecond, time.Unix.
func readXMessage
readXMessage (rd *proto.Reader) (XMessage, error)
References: proto.Nil.
func readXMessageSlice
readXMessageSlice (rd *proto.Reader) ([]XMessage, error)
func replaceLoopbackHost
replaceLoopbackHost (nodeAddr,originHost string) string
References: net.JoinHostPort, net.ParseIP, net.SplitHostPort.
func setCmdsErr
setCmdsErr (cmds []Cmder, e error)
func setupClusterConn
setupClusterConn gets the username and password from the URL and the query parameters.
setupClusterConn (u *url.URL, host string, o *ClusterOptions) (*ClusterOptions, error)
References: fmt.Errorf, tls.Config.
func setupClusterQueryParams
setupClusterQueryParams converts query parameters in u to option value in o.
setupClusterQueryParams (u *url.URL, o *ClusterOptions) (*ClusterOptions, error)
References: fmt.Errorf, net.JoinHostPort, net.SplitHostPort, strings.Join.
func setupConnParams
setupConnParams converts query parameters in u to option value in o.
setupConnParams (u *url.URL, o *Options) (*Options, error)
References: fmt.Errorf, strconv.Atoi, strings.Join.
func setupTCPConn
setupTCPConn (u *url.URL) (*Options, error)
References: fmt.Errorf, net.JoinHostPort, strconv.Atoi, strings.FieldsFunc, tls.Config, tls.VersionTLS12.
func setupUnixConn
setupUnixConn (u *url.URL) (*Options, error)
References: errors.New, strings.TrimSpace.
func shouldRetry
shouldRetry (err error, retryTimeout bool) bool
References: context.Canceled, context.DeadlineExceeded, io.EOF, io.ErrUnexpectedEOF, strings.HasPrefix.
func stringInterfaceMapParser
stringInterfaceMapParser (rd *proto.Reader) (map[string]interface{}, error)
func toBool
toBool (val interface{}) (bool, error)
References: fmt.Errorf, strconv.ParseBool.
func toFloat32
toFloat32 (val interface{}) (float32, error)
References: fmt.Errorf, strconv.ParseFloat.
func toFloat64
toFloat64 (val interface{}) (float64, error)
References: fmt.Errorf, strconv.ParseFloat.
func toInt64
toInt64 (val interface{}) (int64, error)
References: fmt.Errorf, strconv.ParseInt.
func toString
toString (val interface{}) (string, error)
References: fmt.Errorf.
func toUint64
toUint64 (val interface{}) (uint64, error)
References: fmt.Errorf, strconv.ParseUint.
func usePrecise
usePrecise (dur time.Duration) bool
References: time.Second.
func wrapMultiExec
wrapMultiExec (ctx context.Context, cmds []Cmder) []Cmder
func writeCmd
writeCmd (wr *proto.Writer, cmd Cmder) error
func writeCmds
writeCmds (wr *proto.Writer, cmds []Cmder) error
func xAutoClaimArgs
xAutoClaimArgs (ctx context.Context, a *XAutoClaimArgs) []interface{}
func xClaimArgs
xClaimArgs (a *XClaimArgs) []interface{}
References: time.Millisecond.
func newTx
newTx () *Tx
References: pool.NewStickyConnPool.
func checkMovedErr
checkMovedErr (ctx context.Context, cmd Cmder, err error, failedCmds *cmdsMap) bool
func cmdInfo
cmdInfo (ctx context.Context, name string) *CommandInfo
References: context.TODO.
func cmdNode
cmdNode (ctx context.Context, cmdName string, slot int) (*clusterNode, error)
func cmdSlot
cmdSlot (ctx context.Context, cmd Cmder) int
func cmdsAreReadOnly
cmdsAreReadOnly (ctx context.Context, cmds []Cmder) bool
func cmdsInfo
cmdsInfo (ctx context.Context) (map[string]*CommandInfo, error)
References: rand.Perm.
func cmdsMoved
cmdsMoved (ctx context.Context, cmds []Cmder, moved,ask bool, addr string, failedCmds *cmdsMap) error
func context
context (ctx context.Context) context.Context
References: context.Background.
func loadState
loadState (ctx context.Context) (*clusterState, error)
References: rand.Perm.
func mapCmdsByNode
mapCmdsByNode (ctx context.Context, cmdsMap *cmdsMap, cmds []Cmder) error
func mapCmdsBySlot
mapCmdsBySlot (ctx context.Context, cmds []Cmder) map[int][]Cmder
func pipelineReadCmds
pipelineReadCmds (ctx context.Context, node *clusterNode, rd *proto.Reader, cmds []Cmder, failedCmds *cmdsMap) error
func process
process (ctx context.Context, cmd Cmder) error
References: pool.ErrClosed.
func processPipeline
processPipeline (ctx context.Context, cmds []Cmder) error
References: sync.WaitGroup.
func processPipelineNode
processPipelineNode (ctx context.Context, node *clusterNode, cmds []Cmder, failedCmds *cmdsMap)
References: context.Context.
func processPipelineNodeConn
processPipelineNodeConn (ctx context.Context, node *clusterNode, cn *pool.Conn, cmds []Cmder, failedCmds *cmdsMap) error
References: proto.Reader, proto.Writer.
func processTxPipeline
processTxPipeline (ctx context.Context, cmds []Cmder) error
References: sync.WaitGroup.
func processTxPipelineNode
processTxPipelineNode (ctx context.Context, node *clusterNode, cmds []Cmder, failedCmds *cmdsMap)
References: context.Context.
func processTxPipelineNodeConn
processTxPipelineNodeConn (ctx context.Context, node *clusterNode, cn *pool.Conn, cmds []Cmder, failedCmds *cmdsMap) error
References: proto.Reader, proto.Writer.
func pubSub
pubSub () *PubSub
References: context.Context, context.TODO, hashtag.Slot, pool.Conn.
func retryBackoff
retryBackoff (attempt int) time.Duration
func slotReadOnlyNode
slotReadOnlyNode (state *clusterState, slot int) (*clusterNode, error)
func txPipelineReadQueued
txPipelineReadQueued (ctx context.Context, rd *proto.Reader, statusCmd *StatusCmd, cmds []Cmder, failedCmds *cmdsMap) error
References: fmt.Errorf, proto.RespArray.
func clientOptions
clientOptions () *Options
func readReply
readReply (rd *proto.Reader) error
func clusterOptions
clusterOptions () *ClusterOptions
func sentinelOptions
sentinelOptions (addr string) *Options
func readFunctions
readFunctions (rd *proto.Reader) ([]Function, error)
References: fmt.Errorf.
func readCommand
readCommand (rd *proto.Reader) ([]string, error)
func readDuration
readDuration (rd *proto.Reader) (time.Duration, error)
References: time.Duration, time.Millisecond.
func readEngines
readEngines (rd *proto.Reader) ([]Engine, error)
References: fmt.Errorf.
func readRunningScript
readRunningScript (rd *proto.Reader) (RunningScript, bool, error)
References: fmt.Errorf.
func readRunningScripts
readRunningScripts (rd *proto.Reader) ([]RunningScript, bool, error)
func readMatchedPositions
readMatchedPositions (rd *proto.Reader) ([]LCSMatchedPosition, error)
func readPosition
readPosition (rd *proto.Reader) (LCSPosition, error)
func toArgs
toArgs () []interface{}
func readMonitor
readMonitor (rd *proto.Reader, cancel context.CancelFunc) error
func clone
clone () *Options
func init
init ()
References: runtime.GOMAXPROCS, strings.HasPrefix, time.Millisecond, time.Minute, time.Second.
func closeTheCn
closeTheCn (reason error) error
func conn
conn (ctx context.Context, newChannels []string) (*pool.Conn, error)
References: pool.ErrClosed.
func connWithLock
connWithLock (ctx context.Context) (*pool.Conn, error)
func getContext
getContext () context.Context
References: context.Background.
func newMessage
newMessage (reply interface{}) (interface{}, error)
References: fmt.Errorf.
func reconnect
reconnect (ctx context.Context, reason error)
func releaseConn
releaseConn (ctx context.Context, cn *pool.Conn, err error, allowTimeout bool)
func releaseConnWithLock
releaseConnWithLock (ctx context.Context, cn *pool.Conn, err error, allowTimeout bool)
func resubscribe
resubscribe (ctx context.Context, cn *pool.Conn) error
func subscribe
subscribe (ctx context.Context, redisCmd string, channels ...string) error
func cmdShard
cmdShard (ctx context.Context, cmd Cmder) (*ringShard, error)
func args
args (command,key string) []interface{}
func assertUnstableCommand
assertUnstableCommand (cmd Cmder) bool
func cmdTimeout
cmdTimeout (cmd Cmder) time.Duration
References: time.Second.
func dial
dial (ctx context.Context, network,addr string) (net.Conn, error)
func generalProcessPipeline
generalProcessPipeline (ctx context.Context, cmds []Cmder, p pipelineProcessor) error
References: context.Context, pool.Conn.
func getAddr
getAddr () string
func getConn
getConn (ctx context.Context) (*pool.Conn, error)
func initConn
initConn (ctx context.Context, cn *pool.Conn) error
References: pool.NewSingleConnPool.
func newConn
newConn (ctx context.Context) (*pool.Conn, error)
func pipelineProcessCmds
pipelineProcessCmds (ctx context.Context, cn *pool.Conn, cmds []Cmder) (bool, error)
References: proto.Reader, proto.Writer.
func txPipelineProcessCmds
txPipelineProcessCmds (ctx context.Context, cn *pool.Conn, cmds []Cmder) (bool, error)
References: proto.Reader, proto.Writer.
func withConn
withConn (ctx context.Context, fn func(context.Context, *pool.Conn) error) error
func withTimeout
withTimeout (timeout time.Duration) *baseClient
func firstKeyPos
firstKeyPos () int8
func readRawReply
readRawReply (rd *proto.Reader) error
func readTimeout
readTimeout () *time.Duration
func setReadTimeout
setReadTimeout (d time.Duration)
func stringArg
stringArg (pos int) string
References: fmt.Sprint.
func initAllChan
initAllChan must be in sync with initMsgChan.
initAllChan ()
References: context.TODO, pool.ErrClosed, time.Millisecond, time.Minute, time.NewTimer, time.Sleep.
func initHealthCheck
initHealthCheck ()
References: context.TODO, time.Minute, time.NewTimer.
func initMsgChan
initMsgChan must be in sync with initAllChan.
initMsgChan ()
References: context.TODO, pool.ErrClosed, time.Millisecond, time.Minute, time.NewTimer, time.Sleep.
func updateLatency
updateLatency ()
References: atomic.StoreUint32, context.TODO, rand.Intn, time.Duration, time.Microsecond, time.Millisecond, time.Now, time.Since, time.Sleep.
func get
get (addr string) (*clusterNode, error)
References: pool.ErrClosed.
func slotClosestNode
slotClosestNode (slot int) (*clusterNode, error)
References: context.TODO, math.MaxInt64, time.Duration.
func slotMasterNode
slotMasterNode (slot int) (*clusterNode, error)
func slotNodes
slotNodes (slot int) []*clusterNode
References: sort.Search.
func slotRandomNode
slotRandomNode (slot int) (*clusterNode, error)
References: rand.Perm.
func slotSlaveNode
slotSlaveNode (slot int) (*clusterNode, error)
References: rand.Intn.
func setDefaults
setDefaults ()
References: context.Context, net.Conn.
func chain
chain ()
func dialHook
dialHook (ctx context.Context, network,addr string) (net.Conn, error)
func initHooks
initHooks (hooks hooks)
References: sync.Mutex.
func processHook
processHook (ctx context.Context, cmd Cmder) error
func processPipelineHook
processPipelineHook (ctx context.Context, cmds []Cmder) error
func processTxPipelineHook
processTxPipelineHook (ctx context.Context, cmds []Cmder) error
func withProcessHook
withProcessHook (ctx context.Context, cmd Cmder, hook ProcessHook) error
func withProcessPipelineHook
withProcessPipelineHook (ctx context.Context, cmds []Cmder, hook ProcessPipelineHook) error
func bool
bool (name string) bool
References: fmt.Errorf.
func duration
duration (name string) time.Duration
References: fmt.Errorf, strconv.Atoi, time.Duration, time.ParseDuration, time.Second.
func has
has (name string) bool
func int
int (name string) int
References: fmt.Errorf, strconv.Atoi.
func remaining
remaining () []string
References: sort.Strings.
func string
string (name string) string
func strings
strings (name string) []string
func newRingShards
newRingShards (addrs map[string]string, existing *ringShards) (*ringShards, map[string]*ringShard)
func rebalanceLocked
rebalanceLocked removes dead shards from the Ring. Requires c.mu locked.
rebalanceLocked ()
func closeSentinel
closeSentinel () error
func discoverSentinels
discoverSentinels (ctx context.Context)
References: net.JoinHostPort.
func getMasterAddr
getMasterAddr (ctx context.Context, sentinel *SentinelClient) (string, error)
References: net.JoinHostPort.
func getReplicaAddrs
getReplicaAddrs (ctx context.Context, sentinel *SentinelClient) ([]string, error)
func listen
listen (pubsub *PubSub)
References: context.TODO, net.JoinHostPort, strings.Split.
func replicaAddrs
replicaAddrs (ctx context.Context, useDisconnected bool) ([]string, error)
References: context.Canceled, context.DeadlineExceeded, errors.Is, errors.New.
func setSentinel
setSentinel (ctx context.Context, sentinel *SentinelClient)
func trySwitchMaster
trySwitchMaster (ctx context.Context, addr string)
func len
len () int
func bitOp
bitOp (ctx context.Context, op,destKey string, keys ...string) *IntCmd
func eval
eval (ctx context.Context, name,payload string, keys []string, args ...interface{}) *Cmd
func expire
expire (ctx context.Context, key string, expiration time.Duration, mode string) *BoolCmd
func getCfInsertWithArgs
getCfInsertWithArgs (args []interface{}, options *CFInsertOptions, elements ...interface{}) []interface{}
func shutdown
shutdown (ctx context.Context, modifier string) *StatusCmd
References: errors.New, io.EOF.
func xTrim
xTrim If approx is true, add the "~" parameter, otherwise it is the default "=" (redis default). example:
XTRIM key MAXLEN/MINID threshold LIMIT limit.
XTRIM key MAXLEN/MINID ~ threshold LIMIT limit.
The redis-server version is lower than 6.2, please set limit to 0.
xTrim (ctx context.Context, key,strategy string, approx bool, threshold interface{}, limit int64) *IntCmd
func zAddArgs
zAddArgs (key string, args ZAddArgs, incr bool) []interface{}
func zRangeBy
zRangeBy (ctx context.Context, zcmd,key string, opt *ZRangeBy, withScores bool) *StringSliceCmd
func zRevRangeBy
zRevRangeBy (ctx context.Context, zcmd,key string, opt *ZRangeBy) *StringSliceCmd
Tests
Files: 4. Third party imports: 2. Imports from organisation: 0. Tests: 4. Benchmarks: 2.
Vars
var client *Client
var conn *pool.Conn
var ctx = context.TODO()
var initHello = []byte("%1\r\n+proto\r\n:3\r\n")
var state *clusterState
Types
ClientStub
This type doesn't have documentation.
type ClientStub struct {
Cmdable
resp []byte
}
ClientStubFunc
This type doesn't have documentation.
type ClientStubFunc func([]byte) *ClientStub
ConnStub
This type doesn't have documentation.
type ConnStub struct {
init []byte
resp []byte
pos int
}
fixedHash
This type doesn't have documentation.
type fixedHash string
testCounter
This type doesn't have documentation.
type testCounter struct {
mu sync.Mutex
t *testing.T
m map[string]int
}
timeoutErr
This type doesn't have documentation.
type timeoutErr struct {
error
}