Documentation ¶
Overview ¶
Package client is a redis RESP3 protocol only client implementation in go.
Example (Client) ¶
package main import ( "fmt" "log" "github.com/d024441/go-resp3/client" ) func main() { // Open connection with standard host and port: // - if environment variablen REDIS_HOST AND REDIS_PORT are set, // these values are used // - otherwise localhost (127.0.0.1) and Redis default port 6379 are used conn, err := client.Dial("") if err != nil { log.Fatal(err) } defer conn.Close() if err := conn.Set("mykey", "Hello Redis").Err(); err != nil { log.Fatal(err) } value, err := conn.Get("mykey").ToString() if err != nil { log.Fatal(err) } fmt.Println(value) }
Output: Hello Redis
Example (Clientcache) ¶
package main import ( "fmt" "log" "github.com/d024441/go-resp3/client" ) func main() { mykey := client.RandomKey("mykey") // Create cache. cache := client.NewCache() // Create connetion providing cache. dialer := client.Dialer{Cache: cache} conn, err := dialer.Dial("") if err != nil { log.Fatal(err) } defer conn.Close() // Set client tracking on. if err := conn.ClientTracking(true, nil).Err(); err != nil { log.Fatal(err) } // Set key. conn.Set(mykey, "Hello Redis") // Get key. val, err := conn.Get(mykey).Value() if err != nil { log.Fatal(err) } // Save value in cache. cache.Put(mykey, val) // Read value from cache. val, ok := cache.Get(mykey) if !ok { log.Fatal("cache miss") } s, err := val.ToString() if err != nil { log.Fatal(err) } fmt.Println(s) done := make(chan (struct{}), 0) // Change Key in different connection. go func() { conn, err := client.Dial("") if err != nil { log.Fatal(err) } defer conn.Close() // Update key. if err = conn.Set(mykey, "Update mykey").Err(); err != nil { log.Fatal(err) } close(done) }() // Wait for go-routine. <-done // Cache miss: read until cache slot is invalidated. for { if _, ok := cache.Get(mykey); !ok { fmt.Println("Key invalidated") break } } }
Output: Hello Redis Key invalidated
Example (Monitor) ¶
package main import ( "fmt" "log" "github.com/d024441/go-resp3/client" ) import ( "time" ) func Monitor(time time.Time, db int64, addr string, cmd []string) { fmt.Printf("time: %s database: %d address: %s command %v\n", time, db, addr, cmd) } func main() { // Register monitor callback. dialer := client.Dialer{MonitorCallback: Monitor} conn, err := dialer.Dial("") if err != nil { log.Fatal(err) } defer conn.Close() // Start monitor. ok, err := conn.Monitor().ToBool() if err != nil { log.Fatal(err) } if !ok { log.Fatal("Start monitor failed") } // Process some commands in same connection. mykey := client.RandomKey("mykey") for i := 0; i < 5; i++ { if err = conn.Set(mykey, "myValue").Err(); err != nil { log.Fatal(err) } } }
Output:
Example (Pubsub) ¶
package main import ( "fmt" "log" "github.com/d024441/go-resp3/client" ) func MsgCallback(pattern, channel, msg string) { fmt.Printf("Channel: %s Message: %s", channel, msg) } func main() { // Open connection with standard host and port: // - if environment variablen REDIS_HOST AND REDIS_PORT are set, // these values are used // - otherwise localhost (127.0.0.1) and Redis default port 6379 are used conn, err := client.Dial("") if err != nil { log.Fatal(err) } defer conn.Close() // Subscribe channel. if err := conn.Subscribe([]string{"mychannel"}, MsgCallback).Err(); err != nil { log.Fatal(err) } // Connection allows to proceed with any other Redis commands. // Not limited to Subscribe, Psubscribe, Unsubscribe, Punsubscribe, Ping and Quit. if err := conn.Set("mykey", "Hello Redis").Err(); err != nil { log.Fatal(err) } value, err := conn.Get("mykey").ToString() if err != nil { log.Fatal(err) } fmt.Println(value) // Publish message if err := conn.Publish("mychannel", "Hello Redis").Err(); err != nil { log.Fatal(err) } // Unsubscribe channel. if err := conn.Unsubscribe([]string{"mychannel"}).Err(); err != nil { log.Fatal(err) } }
Output: Hello Redis Channel: mychannel Message: Hello Redis
Example (Redefine) ¶
package main // This example shows how to create custom connection and pipeline objects // to extend the command interface or redefine commands. import ( "fmt" "log" "github.com/d024441/go-resp3/client" ) // MyCommands defines redefined and additional commands. type MyCommands interface { // Redefinition of Del - use variadic attribute instead slice. Del(keys ...interface{}) client.Result // Additional command Heartbeat. Heartbeat() client.Result } // Check, that connection and pipeline implement MyCommands. var ( _ MyCommands = (*MyConn)(nil) _ MyCommands = (*MyPipeline)(nil) ) // MyConn is the custom connection. type MyConn struct { client.Conn } // MyConn contructor. func NewMyConn() (*MyConn, error) { conn, err := client.Dial("") if err != nil { return nil, err } return &MyConn{Conn: conn}, nil } // Pipeline overwrites the connection pipeline method. func (c *MyConn) Pipeline() *MyPipeline { return NewMyPipeline(c) } // Del implements MyCommands interface. func (c *MyConn) Del(keys ...interface{}) client.Result { // call client connection method. return c.Conn.Del(keys) } // Heartbeat implements MyCommands interface. func (c *MyConn) Heartbeat() client.Result { // call client connection method // using the generic Do method return c.Conn.Do("ping", "ok") } // MyPipeline is the custom pipeline. type MyPipeline struct { client.Pipeline } // MyPipeline constructor. func NewMyPipeline(c *MyConn) *MyPipeline { return &MyPipeline{Pipeline: c.Conn.Pipeline()} } // Del implements MyCommands interface. func (p *MyPipeline) Del(keys ...interface{}) client.Result { return p.Pipeline.Del(keys) } // Heartbeat implements MyCommands interface. func (p *MyPipeline) Heartbeat() client.Result { return p.Pipeline.Do("ping", "ok") } func main() { // Use custom connection. conn, err := NewMyConn() if err != nil { log.Fatal(err) } defer conn.Close() if err := conn.Set("mykey", "myvalue").Err(); err != nil { log.Fatal(err) } // Use of redefined connection method. removedKeys, err := conn.Del("mykey").ToInt64() if err != nil { log.Fatal(err) } fmt.Println(removedKeys) // Use of extended connection method. ok, err := conn.Heartbeat().ToString() if err != nil { log.Fatal(err) } fmt.Println(ok) // Use custom pipeline. pipeline := conn.Pipeline() set := pipeline.Set("mykey", "myvalue") // Use of redefined pipeline method. del := pipeline.Del("mykey") // Use of extended pipeline method. heartbeat := conn.Heartbeat() pipeline.Flush() if err := set.Err(); err != nil { log.Fatal(err) } removedKeys, err = del.ToInt64() if err != nil { log.Fatal(err) } fmt.Println(removedKeys) ok, err = heartbeat.ToString() if err != nil { log.Fatal(err) } fmt.Println(ok) }
Output: 1 ok 1 ok
Index ¶
- Constants
- Variables
- func Int64Ptr(i int64) *int64
- func RandomKey(key string) string
- func StringPtr(s string) *string
- type Aggregate
- type Booler
- type Cache
- type Clienttype
- type ClusterCommands
- type Commands
- type Conn
- type ConnectionCommands
- type ConversionError
- type Converter
- type Decoder
- type Dialer
- type Encoder
- type FieldValue
- type Float64er
- type GenericCommands
- type GeoCommands
- type GroupConsumer
- type HashCommands
- type HyperloglogCommands
- type IDMap
- type Int64Slicer
- type Int64er
- type InvalidBigNumberError
- type InvalidDoubleError
- type InvalidNumberError
- type InvalidTypeError
- type InvalidValueError
- type Key
- type KeyValue
- type ListCommands
- type LongitudeLatitudeMember
- type Map
- func (m Map) Attr() *Map
- func (m Map) Kind() RedisKind
- func (m Map) ToBool() (bool, error)
- func (m Map) ToFloat64() (float64, error)
- func (m Map) ToInt64() (int64, error)
- func (m Map) ToInt64Slice() ([]int64, error)
- func (m Map) ToSlice() ([]interface{}, error)
- func (m Map) ToSlice2() ([][]interface{}, error)
- func (m Map) ToString() (string, error)
- func (m Map) ToStringInt64Map() (map[string]int64, error)
- func (m Map) ToStringMap() (map[string]interface{}, error)
- func (m Map) ToStringMapSlice() ([]map[string]interface{}, error)
- func (m Map) ToStringSet() (map[string]bool, error)
- func (m Map) ToStringSlice() ([]string, error)
- func (m Map) ToStringStringMap() (map[string]string, error)
- func (m Map) ToTree() ([]interface{}, error)
- func (m Map) ToXrange() ([]IDMap, error)
- func (m Map) ToXread() (map[string][]IDMap, error)
- type MapItem
- type Mode
- type MonitorCallback
- type MsgCallback
- type OffsetCount
- type Overflow
- type Pipeline
- type PubsubCommands
- type RedisError
- type RedisKind
- type RedisValue
- type ReplyMode
- type Result
- type ScoreMember
- type ScriptingCommands
- type SendInterceptor
- type ServerCommands
- type Set
- func (s Set) Attr() *Map
- func (s Set) Kind() RedisKind
- func (s Set) ToBool() (bool, error)
- func (s Set) ToFloat64() (float64, error)
- func (s Set) ToInt64() (int64, error)
- func (s Set) ToInt64Slice() ([]int64, error)
- func (s Set) ToSlice() ([]interface{}, error)
- func (s Set) ToSlice2() ([][]interface{}, error)
- func (s Set) ToString() (string, error)
- func (s Set) ToStringInt64Map() (map[string]int64, error)
- func (s Set) ToStringMap() (map[string]interface{}, error)
- func (s Set) ToStringMapSlice() ([]map[string]interface{}, error)
- func (s Set) ToStringSet() (map[string]bool, error)
- func (s Set) ToStringSlice() ([]string, error)
- func (s Set) ToStringStringMap() (map[string]string, error)
- func (s Set) ToTree() ([]interface{}, error)
- func (s Set) ToXrange() ([]IDMap, error)
- func (s Set) ToXread() (map[string][]IDMap, error)
- type SetCommands
- type Slice
- func (s Slice) Attr() *Map
- func (s Slice) Kind() RedisKind
- func (s Slice) ToBool() (bool, error)
- func (s Slice) ToFloat64() (float64, error)
- func (s Slice) ToInt64() (int64, error)
- func (s Slice) ToInt64Slice() ([]int64, error)
- func (s Slice) ToSlice() ([]interface{}, error)
- func (s Slice) ToSlice2() ([][]interface{}, error)
- func (s Slice) ToString() (string, error)
- func (s Slice) ToStringInt64Map() (map[string]int64, error)
- func (s Slice) ToStringMap() (map[string]interface{}, error)
- func (s Slice) ToStringMapSlice() ([]map[string]interface{}, error)
- func (s Slice) ToStringSet() (map[string]bool, error)
- func (s Slice) ToStringSlice() ([]string, error)
- func (s Slice) ToStringStringMap() (map[string]string, error)
- func (s Slice) ToTree() ([]interface{}, error)
- func (s Slice) ToXrange() ([]IDMap, error)
- func (s Slice) ToXread() (map[string][]IDMap, error)
- type Slice2er
- type Slicer
- type SortedSetCommands
- type StartEnd
- type StartEndCount
- type StreamCommands
- type StringCommands
- type StringInt64Mapper
- type StringMapSlicer
- type StringMapper
- type StringSetter
- type StringSlicer
- type StringStringMapper
- type Stringer
- type TraceCallback
- type TransactionsCommands
- type Treer
- type TypeOffset
- type TypeOffsetIncrement
- type TypeOffsetValue
- type UnexpectedCharacterError
- type Unit
- type UserPassword
- type VerbatimString
- func (s VerbatimString) Attr() *Map
- func (s VerbatimString) FileFormat() string
- func (s VerbatimString) Kind() RedisKind
- func (s VerbatimString) String() string
- func (s VerbatimString) ToBool() (bool, error)
- func (s VerbatimString) ToFloat64() (float64, error)
- func (s VerbatimString) ToInt64() (int64, error)
- func (s VerbatimString) ToInt64Slice() ([]int64, error)
- func (s VerbatimString) ToSlice() ([]interface{}, error)
- func (s VerbatimString) ToSlice2() ([][]interface{}, error)
- func (s VerbatimString) ToString() (string, error)
- func (s VerbatimString) ToStringInt64Map() (map[string]int64, error)
- func (s VerbatimString) ToStringMap() (map[string]interface{}, error)
- func (s VerbatimString) ToStringMapSlice() ([]map[string]interface{}, error)
- func (s VerbatimString) ToStringSet() (map[string]bool, error)
- func (s VerbatimString) ToStringSlice() ([]string, error)
- func (s VerbatimString) ToStringStringMap() (map[string]string, error)
- func (s VerbatimString) ToTree() ([]interface{}, error)
- func (s VerbatimString) ToXrange() ([]IDMap, error)
- func (s VerbatimString) ToXread() (map[string][]IDMap, error)
- type Xranger
- type Xreader
- type Zclose
- type Zfloat64
- type Zopen
Examples ¶
Constants ¶
const ( EnvHost = "REDIS_HOST" EnvPort = "REDIS_PORT" )
Environment variables.
const ( LocalHost = "127.0.0.1" DefaultRedisPort = "6379" )
Default redis host and port.
const ( GroupCluster = "Cluster" GroupConnection = "Connection" GroupGeneric = "Generic" GroupGeo = "Geo" GroupHash = "Hash" GroupHyperloglog = "Hyperloglog" GroupList = "List" GroupPubsub = "Pubsub" GroupScripting = "Scripting" GroupServer = "Server" GroupSet = "Set" GroupSortedSet = "SortedSet" GroupStream = "Stream" GroupString = "String" GroupTransactions = "Transactions" )
const ( CmdAclCat = "AclCat" CmdAclDeluser = "AclDeluser" CmdAclGenpass = "AclGenpass" CmdAclGetuser = "AclGetuser" CmdAclHelp = "AclHelp" CmdAclList = "AclList" CmdAclLoad = "AclLoad" CmdAclSave = "AclSave" CmdAclSetuser = "AclSetuser" CmdAclUsers = "AclUsers" CmdAclWhoami = "AclWhoami" CmdAppend = "Append" CmdAuth = "Auth" CmdBgrewriteaof = "Bgrewriteaof" CmdBgsave = "Bgsave" CmdBitcount = "Bitcount" CmdBitfield = "Bitfield" CmdBitopAnd = "BitopAnd" CmdBitopNot = "BitopNot" CmdBitopOr = "BitopOr" CmdBitopXor = "BitopXor" CmdBitpos = "Bitpos" CmdBlpop = "Blpop" CmdBrpop = "Brpop" CmdBrpoplpush = "Brpoplpush" CmdBzpopmax = "Bzpopmax" CmdBzpopmin = "Bzpopmin" CmdClientGetname = "ClientGetname" CmdClientId = "ClientId" CmdClientKill = "ClientKill" CmdClientList = "ClientList" CmdClientPause = "ClientPause" CmdClientReply = "ClientReply" CmdClientSetname = "ClientSetname" CmdClientTracking = "ClientTracking" CmdClientUnblock = "ClientUnblock" CmdClusterAddslots = "ClusterAddslots" CmdClusterBumpepoch = "ClusterBumpepoch" CmdClusterCountFailureReports = "ClusterCountFailureReports" CmdClusterCountkeysinslot = "ClusterCountkeysinslot" CmdClusterDelslots = "ClusterDelslots" CmdClusterFailover = "ClusterFailover" CmdClusterFlushslots = "ClusterFlushslots" CmdClusterForget = "ClusterForget" CmdClusterGetkeysinslot = "ClusterGetkeysinslot" CmdClusterInfo = "ClusterInfo" CmdClusterKeyslot = "ClusterKeyslot" CmdClusterMeet = "ClusterMeet" CmdClusterMyid = "ClusterMyid" CmdClusterNodes = "ClusterNodes" CmdClusterReplicas = "ClusterReplicas" CmdClusterReplicate = "ClusterReplicate" CmdClusterReset = "ClusterReset" CmdClusterSaveconfig = "ClusterSaveconfig" CmdClusterSetConfigEpoch = "ClusterSetConfigEpoch" CmdClusterSetslotImporting = "ClusterSetslotImporting" CmdClusterSetslotMigrating = "ClusterSetslotMigrating" CmdClusterSetslotNode = "ClusterSetslotNode" CmdClusterSetslotStable = "ClusterSetslotStable" CmdClusterSlaves = "ClusterSlaves" CmdClusterSlots = "ClusterSlots" CmdCommand = "Command" CmdCommandCount = "CommandCount" CmdCommandGetkeys = "CommandGetkeys" CmdCommandInfo = "CommandInfo" CmdConfigGet = "ConfigGet" CmdConfigResetstat = "ConfigResetstat" CmdConfigRewrite = "ConfigRewrite" CmdConfigSet = "ConfigSet" CmdDbsize = "Dbsize" CmdDebugObject = "DebugObject" CmdDebugSegfault = "DebugSegfault" CmdDecr = "Decr" CmdDecrby = "Decrby" CmdDel = "Del" CmdDiscard = "Discard" CmdDo = "Do" CmdDump = "Dump" CmdEcho = "Echo" CmdEval = "Eval" CmdEvalsha = "Evalsha" CmdExec = "Exec" CmdExists = "Exists" CmdExpire = "Expire" CmdExpireat = "Expireat" CmdFlushall = "Flushall" CmdFlushdb = "Flushdb" CmdGeoadd = "Geoadd" CmdGeodist = "Geodist" CmdGeohash = "Geohash" CmdGeopos = "Geopos" CmdGeoradius = "Georadius" CmdGeoradiusbymember = "Georadiusbymember" CmdGet = "Get" CmdGetbit = "Getbit" CmdGetrange = "Getrange" CmdGetset = "Getset" CmdHdel = "Hdel" CmdHello = "Hello" CmdHexists = "Hexists" CmdHget = "Hget" CmdHgetall = "Hgetall" CmdHincrby = "Hincrby" CmdHincrbyfloat = "Hincrbyfloat" CmdHkeys = "Hkeys" CmdHlen = "Hlen" CmdHmget = "Hmget" CmdHscan = "Hscan" CmdHset = "Hset" CmdHsetNx = "HsetNx" CmdHstrlen = "Hstrlen" CmdHvals = "Hvals" CmdIncr = "Incr" CmdIncrby = "Incrby" CmdIncrbyfloat = "Incrbyfloat" CmdInfo = "Info" CmdKeys = "Keys" CmdLastsave = "Lastsave" CmdLatencyDoctor = "LatencyDoctor" CmdLatencyGraph = "LatencyGraph" CmdLatencyHelp = "LatencyHelp" CmdLatencyHistory = "LatencyHistory" CmdLatencyLatest = "LatencyLatest" CmdLatencyReset = "LatencyReset" CmdLindex = "Lindex" CmdLinsert = "Linsert" CmdLlen = "Llen" CmdLolwut = "Lolwut" CmdLpop = "Lpop" CmdLpush = "Lpush" CmdLpushx = "Lpushx" CmdLrange = "Lrange" CmdLrem = "Lrem" CmdLset = "Lset" CmdLtrim = "Ltrim" CmdMemoryDoctor = "MemoryDoctor" CmdMemoryHelp = "MemoryHelp" CmdMemoryMallocStats = "MemoryMallocStats" CmdMemoryPurge = "MemoryPurge" CmdMemoryStats = "MemoryStats" CmdMemoryUsage = "MemoryUsage" CmdMget = "Mget" CmdMigrate = "Migrate" CmdModuleList = "ModuleList" CmdModuleLoad = "ModuleLoad" CmdModuleUnload = "ModuleUnload" CmdMonitor = "Monitor" CmdMove = "Move" CmdMset = "Mset" CmdMsetNx = "MsetNx" CmdMulti = "Multi" CmdObjectEncoding = "ObjectEncoding" CmdObjectFreq = "ObjectFreq" CmdObjectHelp = "ObjectHelp" CmdObjectIdletime = "ObjectIdletime" CmdObjectRefcount = "ObjectRefcount" CmdPTTL = "PTTL" CmdPersist = "Persist" CmdPexpire = "Pexpire" CmdPexpireat = "Pexpireat" CmdPfadd = "Pfadd" CmdPfcount = "Pfcount" CmdPfmerge = "Pfmerge" CmdPing = "Ping" CmdPsubscribe = "Psubscribe" CmdPsync = "Psync" CmdPublish = "Publish" CmdPubsubChannels = "PubsubChannels" CmdPubsubNumpat = "PubsubNumpat" CmdPubsubNumsub = "PubsubNumsub" CmdPunsubscribe = "Punsubscribe" CmdQuit = "Quit" CmdRandomkey = "Randomkey" CmdReadonly = "Readonly" CmdReadwrite = "Readwrite" CmdRename = "Rename" CmdRenameNx = "RenameNx" CmdReplicaof = "Replicaof" CmdRestore = "Restore" CmdRole = "Role" CmdRpop = "Rpop" CmdRpoplpush = "Rpoplpush" CmdRpush = "Rpush" CmdRpushx = "Rpushx" CmdSadd = "Sadd" CmdSave = "Save" CmdScan = "Scan" CmdScard = "Scard" CmdScriptDebug = "ScriptDebug" CmdScriptExists = "ScriptExists" CmdScriptFlush = "ScriptFlush" CmdScriptKill = "ScriptKill" CmdScriptLoad = "ScriptLoad" CmdSdiff = "Sdiff" CmdSdiffstore = "Sdiffstore" CmdSelect = "Select" CmdSet = "Set" CmdSetEx = "SetEx" CmdSetExNx = "SetExNx" CmdSetExXx = "SetExXx" CmdSetNx = "SetNx" CmdSetPx = "SetPx" CmdSetPxNx = "SetPxNx" CmdSetPxXx = "SetPxXx" CmdSetXx = "SetXx" CmdSetbit = "Setbit" CmdSetrange = "Setrange" CmdShutdown = "Shutdown" CmdSinter = "Sinter" CmdSinterstore = "Sinterstore" CmdSismember = "Sismember" CmdSlowlogGet = "SlowlogGet" CmdSlowlogLen = "SlowlogLen" CmdSlowlogReset = "SlowlogReset" CmdSmembers = "Smembers" CmdSmove = "Smove" CmdSort = "Sort" CmdSpop = "Spop" CmdSrandmember = "Srandmember" CmdSrem = "Srem" CmdSscan = "Sscan" CmdStrlen = "Strlen" CmdSubscribe = "Subscribe" CmdSunion = "Sunion" CmdSunionstore = "Sunionstore" CmdSwapdb = "Swapdb" CmdTTL = "TTL" CmdTime = "Time" CmdTouch = "Touch" CmdType = "Type" CmdUnlink = "Unlink" CmdUnsubscribe = "Unsubscribe" CmdUnwatch = "Unwatch" CmdWait = "Wait" CmdWatch = "Watch" CmdXack = "Xack" CmdXadd = "Xadd" CmdXclaim = "Xclaim" CmdXdel = "Xdel" CmdXgroupCreate = "XgroupCreate" CmdXgroupDelconsumer = "XgroupDelconsumer" CmdXgroupDestroy = "XgroupDestroy" CmdXgroupHelp = "XgroupHelp" CmdXgroupSetid = "XgroupSetid" CmdXinfoConsumers = "XinfoConsumers" CmdXinfoGroups = "XinfoGroups" CmdXinfoHelp = "XinfoHelp" CmdXinfoStream = "XinfoStream" CmdXlen = "Xlen" CmdXpending = "Xpending" CmdXrange = "Xrange" CmdXread = "Xread" CmdXreadgroup = "Xreadgroup" CmdXrevrange = "Xrevrange" CmdXtrim = "Xtrim" CmdZadd = "Zadd" CmdZaddCh = "ZaddCh" CmdZaddNx = "ZaddNx" CmdZaddXx = "ZaddXx" CmdZaddXxCh = "ZaddXxCh" CmdZcard = "Zcard" CmdZcount = "Zcount" CmdZincrby = "Zincrby" CmdZinterstore = "Zinterstore" CmdZlexcount = "Zlexcount" CmdZpopmax = "Zpopmax" CmdZpopmin = "Zpopmin" CmdZrange = "Zrange" CmdZrangebylex = "Zrangebylex" CmdZrangebyscore = "Zrangebyscore" CmdZrank = "Zrank" CmdZrem = "Zrem" CmdZremrangebylex = "Zremrangebylex" CmdZremrangebyrank = "Zremrangebyrank" CmdZremrangebyscore = "Zremrangebyscore" CmdZrevrange = "Zrevrange" CmdZrevrangebylex = "Zrevrangebylex" CmdZrevrangebyscore = "Zrevrangebyscore" CmdZrevrank = "Zrevrank" CmdZscan = "Zscan" CmdZscore = "Zscore" CmdZunionstore = "Zunionstore" )
const ( ReplyOK = "OK" ReplyQueued = "QUEUED" )
Redis reply constants.
Variables ¶
var ( // InfPos can be used as infinite positive value for Zfloat64 parameters. InfPos = Zclose(math.Inf(+1)) // InfNeg can be used as infinite negative value for Zfloat64 parameters. InfNeg = Zclose(math.Inf(-1)) )
var CommandNames = []string{} /* 282 elements not displayed */
var ErrInShutdown = errors.New("connection is shutdown")
ErrInShutdown is returned by a command executed during client is in shutdown status.
var ErrNotFlushed = errors.New("pipeline: not flushed")
ErrNotFlushed is returned by a command executed in a unflushed pipeline.
var ErrTimeout = errors.New("timeout while waiting for result")
ErrTimeout is returned by a command after timeout is reached before a async Redis result is available.
var Groups = map[string][]string{GroupCluster: {CmdClusterAddslots, CmdClusterBumpepoch, CmdClusterCountFailureReports, CmdClusterCountkeysinslot, CmdClusterDelslots, CmdClusterFailover, CmdClusterFlushslots, CmdClusterForget, CmdClusterGetkeysinslot, CmdClusterInfo, CmdClusterKeyslot, CmdClusterMeet, CmdClusterMyid, CmdClusterNodes, CmdClusterReplicas, CmdClusterReplicate, CmdClusterReset, CmdClusterSaveconfig, CmdClusterSetConfigEpoch, CmdClusterSetslotImporting, CmdClusterSetslotMigrating, CmdClusterSetslotNode, CmdClusterSetslotStable, CmdClusterSlaves, CmdClusterSlots, CmdReadonly, CmdReadwrite}, GroupConnection: {CmdAclCat, CmdAclDeluser, CmdAclGenpass, CmdAclGetuser, CmdAclHelp, CmdAclList, CmdAclLoad, CmdAclSave, CmdAclSetuser, CmdAclUsers, CmdAclWhoami, CmdAuth, CmdEcho, CmdHello, CmdPing, CmdQuit, CmdSelect, CmdSwapdb}, GroupGeneric: {CmdDel, CmdDo, CmdDump, CmdExists, CmdExpire, CmdExpireat, CmdKeys, CmdMigrate, CmdMove, CmdObjectEncoding, CmdObjectFreq, CmdObjectHelp, CmdObjectIdletime, CmdObjectRefcount, CmdPTTL, CmdPersist, CmdPexpire, CmdPexpireat, CmdRandomkey, CmdRename, CmdRenameNx, CmdRestore, CmdScan, CmdSort, CmdTTL, CmdTouch, CmdType, CmdUnlink, CmdWait}, GroupGeo: {CmdGeoadd, CmdGeodist, CmdGeohash, CmdGeopos, CmdGeoradius, CmdGeoradiusbymember}, GroupHash: {CmdHdel, CmdHexists, CmdHget, CmdHgetall, CmdHincrby, CmdHincrbyfloat, CmdHkeys, CmdHlen, CmdHmget, CmdHscan, CmdHset, CmdHsetNx, CmdHstrlen, CmdHvals}, GroupHyperloglog: {CmdPfadd, CmdPfcount, CmdPfmerge}, GroupList: {CmdBlpop, CmdBrpop, CmdBrpoplpush, CmdLindex, CmdLinsert, CmdLlen, CmdLpop, CmdLpush, CmdLpushx, CmdLrange, CmdLrem, CmdLset, CmdLtrim, CmdRpop, CmdRpoplpush, CmdRpush, CmdRpushx}, GroupPubsub: {CmdPsubscribe, CmdPublish, CmdPubsubChannels, CmdPubsubNumpat, CmdPubsubNumsub, CmdPunsubscribe, CmdSubscribe, CmdUnsubscribe}, GroupScripting: {CmdEval, CmdEvalsha, CmdScriptDebug, CmdScriptExists, CmdScriptFlush, CmdScriptKill, CmdScriptLoad}, GroupServer: {CmdBgrewriteaof, CmdBgsave, CmdClientGetname, CmdClientId, CmdClientKill, CmdClientList, CmdClientPause, CmdClientReply, CmdClientSetname, CmdClientTracking, CmdClientUnblock, CmdCommand, CmdCommandCount, CmdCommandGetkeys, CmdCommandInfo, CmdConfigGet, CmdConfigResetstat, CmdConfigRewrite, CmdConfigSet, CmdDbsize, CmdDebugObject, CmdDebugSegfault, CmdFlushall, CmdFlushdb, CmdInfo, CmdLastsave, CmdLatencyDoctor, CmdLatencyGraph, CmdLatencyHelp, CmdLatencyHistory, CmdLatencyLatest, CmdLatencyReset, CmdLolwut, CmdMemoryDoctor, CmdMemoryHelp, CmdMemoryMallocStats, CmdMemoryPurge, CmdMemoryStats, CmdMemoryUsage, CmdModuleList, CmdModuleLoad, CmdModuleUnload, CmdMonitor, CmdPsync, CmdReplicaof, CmdRole, CmdSave, CmdShutdown, CmdSlowlogGet, CmdSlowlogLen, CmdSlowlogReset, CmdTime}, GroupSet: {CmdSadd, CmdScard, CmdSdiff, CmdSdiffstore, CmdSinter, CmdSinterstore, CmdSismember, CmdSmembers, CmdSmove, CmdSpop, CmdSrandmember, CmdSrem, CmdSscan, CmdSunion, CmdSunionstore}, GroupSortedSet: {CmdBzpopmax, CmdBzpopmin, CmdZadd, CmdZaddCh, CmdZaddNx, CmdZaddXx, CmdZaddXxCh, CmdZcard, CmdZcount, CmdZincrby, CmdZinterstore, CmdZlexcount, CmdZpopmax, CmdZpopmin, CmdZrange, CmdZrangebylex, CmdZrangebyscore, CmdZrank, CmdZrem, CmdZremrangebylex, CmdZremrangebyrank, CmdZremrangebyscore, CmdZrevrange, CmdZrevrangebylex, CmdZrevrangebyscore, CmdZrevrank, CmdZscan, CmdZscore, CmdZunionstore}, GroupStream: {CmdXack, CmdXadd, CmdXclaim, CmdXdel, CmdXgroupCreate, CmdXgroupDelconsumer, CmdXgroupDestroy, CmdXgroupHelp, CmdXgroupSetid, CmdXinfoConsumers, CmdXinfoGroups, CmdXinfoHelp, CmdXinfoStream, CmdXlen, CmdXpending, CmdXrange, CmdXread, CmdXreadgroup, CmdXrevrange, CmdXtrim}, GroupString: {CmdAppend, CmdBitcount, CmdBitfield, CmdBitopAnd, CmdBitopNot, CmdBitopOr, CmdBitopXor, CmdBitpos, CmdDecr, CmdDecrby, CmdGet, CmdGetbit, CmdGetrange, CmdGetset, CmdIncr, CmdIncrby, CmdIncrbyfloat, CmdMget, CmdMset, CmdMsetNx, CmdSet, CmdSetEx, CmdSetExNx, CmdSetExXx, CmdSetNx, CmdSetPx, CmdSetPxNx, CmdSetPxXx, CmdSetXx, CmdSetbit, CmdSetrange, CmdStrlen}, GroupTransactions: {CmdDiscard, CmdExec, CmdMulti, CmdUnwatch, CmdWatch}}
Functions ¶
Types ¶
type Booler ¶
type Booler interface { // ToBooler converts a redis value to a bool. // In case the conversion is not supported a ConversionError is returned. ToBool() (bool, error) }
Booler is implemented by any redis value that has a ToBool method.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a key cache supporting Redis client side caching.
func NewCacheSize ¶
NewCacheSize creates a new ClientCache instance with size slot entries.
func (*Cache) Get ¶
func (c *Cache) Get(key string) (RedisValue, bool)
Get reads the value of a key from the cache.
func (*Cache) Put ¶
func (c *Cache) Put(key string, value RedisValue)
Put inserts a key into the cache.
type Clienttype ¶
type Clienttype string
const ( ClienttypeNormal Clienttype = "normal" ClienttypeMaster Clienttype = "master" ClienttypeReplica Clienttype = "replica" ClienttypePubsub Clienttype = "pubsub" )
type ClusterCommands ¶
type ClusterCommands interface { ClusterAddslots(slot []int64) Result ClusterBumpepoch() Result ClusterCountFailureReports(nodeId string) Result ClusterCountkeysinslot(slot int64) Result ClusterDelslots(slot []int64) Result ClusterFailover(force *bool) Result ClusterFlushslots() Result ClusterForget(nodeId string) Result ClusterGetkeysinslot(slot, count int64) Result ClusterInfo() Result ClusterKeyslot(key string) Result ClusterMeet(ip string, port int64) Result ClusterMyid() Result ClusterNodes() Result ClusterReplicas(nodeId string) Result ClusterReplicate(nodeId string) Result ClusterReset(hard *bool) Result ClusterSaveconfig() Result ClusterSetConfigEpoch(configEpoch int64) Result ClusterSetslotImporting(slot int64, sourceNodeId string) Result ClusterSetslotMigrating(slot int64, destNodeId string) Result ClusterSetslotNode(slot int64, nodeId string) Result ClusterSetslotStable(slot int64) Result ClusterSlaves(nodeId string) Result ClusterSlots() Result Readonly() Result Readwrite() Result }
type Conn ¶
Conn represents the redis network connection.
Example (Tracing) ¶
package main import ( "fmt" "log" "strconv" "github.com/d024441/go-resp3/client" ) func trace(dir bool, b []byte) { if dir { // Example: print sent commands only. fmt.Println(strconv.Quote(string(b))) } } func main() { // Create connetion providing trace callback. dialer := client.Dialer{TraceCallback: trace} conn, err := dialer.Dial("") if err != nil { log.Fatal(err) } defer conn.Close() if err := conn.Set("mykey", "Hello Redis").Err(); err != nil { log.Fatal(err) } if err := conn.Get("mykey").Err(); err != nil { log.Fatal(err) } }
Output: "*2\r\n$5\r\nHELLO\r\n$1\r\n3\r\n" "*3\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$11\r\nHello Redis\r\n" "*2\r\n$3\r\nGET\r\n$5\r\nmykey\r\n" "*1\r\n$4\r\nQUIT\r\n"
type ConnectionCommands ¶
type ConnectionCommands interface { AclCat(category *string) Result AclDeluser(username []string) Result AclGenpass() Result AclGetuser(username string) Result AclHelp() Result AclList() Result AclLoad() Result AclSave() Result AclSetuser(username string, rules []string) Result AclUsers() Result AclWhoami() Result Auth(username *string, password string) Result Echo(message string) Result Hello(version string, userPassword *UserPassword, clientName *string) Result Ping(message *string) Result Quit() Result Select(index int64) Result Swapdb(index1, index2 int64) Result }
type ConversionError ¶
type ConversionError struct { To string Value interface{} }
A ConversionError is raised for an unsuccessful type conversion of a redis value. - To: Name of the conversion function. - Value: Value for which the conversion was not successful.
func (*ConversionError) Error ¶
func (e *ConversionError) Error() string
type Converter ¶
type Converter interface { Stringer Int64er Float64er Booler Int64Slicer Slicer Slice2er StringMapSlicer StringSlicer Treer Xranger StringMapper StringInt64Mapper StringStringMapper Xreader StringSetter }
Converter is the interface that groups Redis value conversion interfaces.
type Decoder ¶
type Decoder interface {
Decode() (interface{}, error)
}
Decoder is the interface that wraps the Decode method.
func NewDecoder ¶
NewDecoder returns a Decoder for Redis results.
type Dialer ¶
type Dialer struct { net.Dialer // TLS TLSConfig *tls.Config // Connection logging. Logger *log.Logger // Channel size for asynchronous result reader and handler. ChannelSize int // Duration to wait for async results before timeout. AsyncTimeout time.Duration // Redis authentication. User, Password string // Redis client name. ClientName string // Client cache. Cache *Cache // Monitor callback. MonitorCallback MonitorCallback // Callback function tracing Redis commands and results on RESP3 protocol level. // Direction dir is true for sent bytes b (commands), false for received bytes b (results). TraceCallback TraceCallback // Command interceptor (debugging). SendInterceptor SendInterceptor }
Dialer contains options for connecting to a redis server.
type Encoder ¶
Encoder is the interface that wraps the Encode method.
Encode is not a general redis encoder but encodes redis commands only. Redis commands are send as ARRAY of BULK STRINGS. Encode is encoding all elements of v to BULK STRINGS. In case an element is a not suported type, Encode will panic.
func NewEncoder ¶
NewEncoder returns an Encoder for redis commands.
type FieldValue ¶
type FieldValue struct { Field interface{} Value interface{} }
type Float64er ¶
type Float64er interface { // ToFloat64 converts a redis value to a float64. // In case the conversion is not supported a ConversionError is returned. ToFloat64() (float64, error) }
Float64er is implemented by any redis value that has a ToFloat64 method.
type GenericCommands ¶
type GenericCommands interface { Del(key []interface{}) Result Do(v ...interface{}) Result Dump(key interface{}) Result Exists(key []interface{}) Result Expire(key interface{}, seconds int64) Result Expireat(key interface{}, timestamp int64) Result Keys(pattern string) Result Migrate(host, port string, key interface{}, destinationDb, timeout int64, copy, replace bool, auth *string, keys []interface{}) Result Move(key interface{}, db int64) Result ObjectEncoding(key interface{}) Result ObjectFreq(key interface{}) Result ObjectHelp() Result ObjectIdletime(key interface{}) Result ObjectRefcount(key interface{}) Result PTTL(key interface{}) Result Persist(key interface{}) Result Pexpire(key interface{}, milliseconds int64) Result Pexpireat(key interface{}, millisecondsTimestamp int64) Result Randomkey() Result Rename(key, newkey interface{}) Result RenameNx(key, newkey interface{}) Result Restore(key interface{}, ttl int64, serializedValue string, replace, absttl bool, idletime, freq *int64) Result Scan(cursor int64, match *string, count *int64, typ *string) Result Sort(key interface{}, by *string, limit *OffsetCount, get []string, asc *bool, sorting bool, store *interface{}) Result TTL(key interface{}) Result Touch(key []interface{}) Result Type(key interface{}) Result Unlink(key []interface{}) Result Wait(numreplicas, timeout int64) Result }
type GeoCommands ¶
type GeoCommands interface { Geoadd(key interface{}, longitudeLatitudeMember []LongitudeLatitudeMember) Result Geodist(key, member1, member2 interface{}, unit *Unit) Result Geohash(key interface{}, member []interface{}) Result Geopos(key interface{}, member []interface{}) Result Georadius(key interface{}, longitude, latitude, radius float64, unit Unit, withcoord, withdist, withhash bool, count *int64, asc *bool, store, storedist *interface{}) Result Georadiusbymember(key, member interface{}, radius float64, unit Unit, withcoord, withdist, withhash bool, count *int64, asc *bool, store, storedist *interface{}) Result }
type GroupConsumer ¶
type HashCommands ¶
type HashCommands interface { Hdel(key interface{}, field []interface{}) Result Hexists(key, field interface{}) Result Hget(key, field interface{}) Result Hgetall(key interface{}) Result Hincrby(key, field interface{}, increment int64) Result Hincrbyfloat(key, field interface{}, increment float64) Result Hkeys(key interface{}) Result Hlen(key interface{}) Result Hmget(key interface{}, field []interface{}) Result Hscan(key interface{}, cursor int64, match *string, count *int64) Result Hset(key interface{}, fieldValue []FieldValue) Result HsetNx(key, field, value interface{}) Result Hstrlen(key, field interface{}) Result Hvals(key interface{}) Result }
type HyperloglogCommands ¶
type Int64Slicer ¶
type Int64Slicer interface { // ToInt64Slice returns a slice with values of type int64. In case value conversion to string is not possible // a ConversitionError is returned. ToInt64Slice() ([]int64, error) }
Int64Slicer is implemented by any redis value that has a ToInt64Slice method.
type Int64er ¶
type Int64er interface { // ToInt64 converts a redis value to an int64. // In case the conversion is not supported a ConversionError is returned. ToInt64() (int64, error) }
Int64er is implemented by any redis value that has a ToInt64 method.
type InvalidBigNumberError ¶
type InvalidBigNumberError struct {
Value string
}
An InvalidBigNumberError is raised by decoding a bignumber including unexpected characters.
func (*InvalidBigNumberError) Error ¶
func (e *InvalidBigNumberError) Error() string
type InvalidDoubleError ¶
type InvalidDoubleError struct {
Value string
}
An InvalidDoubleError is raised by decoding a double including unexpected characters.
func (*InvalidDoubleError) Error ¶
func (e *InvalidDoubleError) Error() string
type InvalidNumberError ¶
type InvalidNumberError struct {
Value string
}
An InvalidNumberError is raised by decoding a number including unexpected characters.
func (*InvalidNumberError) Error ¶
func (e *InvalidNumberError) Error() string
type InvalidTypeError ¶
type InvalidTypeError struct {
Value interface{}
}
An InvalidTypeError is raised by encoding an unsupported value type.
func (*InvalidTypeError) Error ¶
func (e *InvalidTypeError) Error() string
type InvalidValueError ¶
type InvalidValueError struct { Name string Value interface{} }
A InvalidValueError is raised by a redis commend provided with an invalid parameter value. - Name: Parameter name. - Value: Invalid value.
func (*InvalidValueError) Error ¶
func (e *InvalidValueError) Error() string
type Key ¶
type Key string
Key provides methods to calculate Redis crc64 hash and client caching slot.
type ListCommands ¶
type ListCommands interface { Blpop(key []interface{}, timeout int64) Result Brpop(key []interface{}, timeout int64) Result Brpoplpush(source, destination interface{}, timeout int64) Result Lindex(key interface{}, index int64) Result Linsert(key interface{}, before bool, pivot, element interface{}) Result Llen(key interface{}) Result Lpop(key interface{}) Result Lpush(key interface{}, element []interface{}) Result Lpushx(key interface{}, element []interface{}) Result Lrange(key interface{}, start, stop int64) Result Lrem(key interface{}, count int64, element interface{}) Result Lset(key interface{}, index int64, element interface{}) Result Ltrim(key interface{}, start, stop int64) Result Rpop(key interface{}) Result Rpoplpush(source, destination interface{}) Result Rpush(key interface{}, element []interface{}) Result Rpushx(key interface{}, element []interface{}) Result }
type LongitudeLatitudeMember ¶
type Map ¶
type Map []MapItem
A Map represents the redis map type.
func (Map) ToInt64Slice ¶
func (Map) ToStringInt64Map ¶
ToStringInt64Map returns a map with keys of type string and values of type int64. In case key or value conversion is not possible a ConvertionError is returned.
func (Map) ToStringMap ¶
ToStringMap returns a map with keys of type string. In case key conversion to string is not possible a ConvertionError is returned.
func (Map) ToStringMapSlice ¶
func (Map) ToStringSlice ¶
func (Map) ToStringStringMap ¶
ToStringStringMap returns a map with keys and values of type string. In case key or value conversion to string is not possible a ConvertionError is returned.
type MapItem ¶
type MapItem struct { Key RedisValue Value RedisValue }
A MapItem represents the redis map type key and value.
type MonitorCallback ¶
MonitorCallback is the function type for the Redis monitor callback function.
type MsgCallback ¶
type MsgCallback func(pattern, channel, msg string)
MsgCallback is the function type for Redis pubsub message callback functions.
type OffsetCount ¶
type Pipeline ¶
Pipeline supports redis pipelining capabilities. Multiple goroutines must not invoke methods on a Pipeline simultaneously.
type PubsubCommands ¶
type PubsubCommands interface { Psubscribe(pattern []string, cb MsgCallback) Result Publish(channel, message string) Result PubsubChannels(pattern *string) Result PubsubNumpat() Result PubsubNumsub(channel []string) Result Punsubscribe(pattern []string) Result Subscribe(channel []string, cb MsgCallback) Result Unsubscribe(channel []string) Result }
type RedisError ¶
A RedisError represents the redis error message if a redis command was executed unsuccessfully.
func (*RedisError) Error ¶
func (e *RedisError) Error() string
type RedisKind ¶
type RedisKind byte
RedisKind represents the kind of type that a RedisValue represents.
type RedisValue ¶
RedisValue represents a Redis command reply value.
type Result ¶
type Result interface { // Attr returns the attribute of a Redis value if provided - <nil> otherwise. Attr() (*Map, error) // Err returns any of the following errors: // - <nil>: result received successfully. // - ErrNotFlushed: result not received yet (pipeline not flushed). // - ErrTimeout: timeout reached before result is available. // - RedisError: redis error message if a redis command was executed unsuccessfully. Err() error // IsNull returns <true> if the redis value is null. IsNull() (bool, error) // Kind returns the type of a Redis value. Kind() (RedisKind, error) // Value returns a Redis value. Value() (RedisValue, error) // VerbatimString returns a VerbatimString if the Redis type is a verbatim string. VerbatimString() (VerbatimString, error) // Map returns a Map if the Redis type is a map. Map() (Map, error) // Set returns a Set if the Redis type is a set. Set() (Set, error) // Slice returns a Slice if the Redis type is an array. Slice() (Slice, error) // Conversion methods. Converter }
Result represents a redis command result.
type ScoreMember ¶
type ScoreMember struct { Score float64 Member interface{} }
type ScriptingCommands ¶
type ScriptingCommands interface { Eval(script string, numkeys int64, key, arg []interface{}) Result Evalsha(sha1 string, numkeys int64, key, arg []interface{}) Result ScriptDebug(mode Mode) Result ScriptExists(sha1 []string) Result ScriptFlush() Result ScriptKill() Result ScriptLoad(script string) Result }
type SendInterceptor ¶
type SendInterceptor func(name string, values []interface{})
SendInterceptor is the function type for the send interceptor function.
type ServerCommands ¶
type ServerCommands interface { Bgrewriteaof() Result Bgsave() Result ClientGetname() Result ClientId() Result ClientKill(id *int64, typ *Clienttype, addr *string, skipme bool) Result ClientList(typ *Clienttype) Result ClientPause(timeout int64) Result ClientReply(replyMode ReplyMode) Result ClientSetname(connectionName string) Result ClientTracking(on bool, redirect *int64) Result ClientUnblock(clientId int64, timeout *bool) Result Command() Result CommandCount() Result CommandGetkeys(arg []interface{}) Result CommandInfo(commandName []string) Result ConfigGet(parameter string) Result ConfigResetstat() Result ConfigRewrite() Result ConfigSet(parameter, value string) Result Dbsize() Result DebugObject(key interface{}) Result DebugSegfault() Result Flushall(async bool) Result Flushdb(async bool) Result Info(section *string) Result Lastsave() Result LatencyDoctor() Result LatencyGraph(event string) Result LatencyHelp() Result LatencyHistory(event string) Result LatencyLatest() Result LatencyReset(event *string) Result Lolwut(version *int64) Result MemoryDoctor() Result MemoryHelp() Result MemoryMallocStats() Result MemoryPurge() Result MemoryStats() Result MemoryUsage(key interface{}, samples *int64) Result ModuleList() Result ModuleLoad(path string, arg []string) Result ModuleUnload(name string) Result Monitor() Result Psync(replicationid, offset int64) Result Replicaof(host, port string) Result Role() Result Save() Result Shutdown(nosave *bool) Result SlowlogGet(count *int64) Result SlowlogLen() Result SlowlogReset() Result Time() Result }
type Set ¶
type Set []RedisValue
A Set represents the redis set type.
func (Set) ToInt64Slice ¶
func (Set) ToStringMap ¶
func (Set) ToStringMapSlice ¶
func (Set) ToStringSet ¶
ToStringSet returns a map with keys of type string and boolean true values. In case key conversion to string is not possible a ConvertionError is returned.
func (Set) ToStringSlice ¶
type SetCommands ¶
type SetCommands interface { Sadd(key interface{}, member []interface{}) Result Scard(key interface{}) Result Sdiff(key []interface{}) Result Sdiffstore(destination interface{}, key []interface{}) Result Sinter(key []interface{}) Result Sinterstore(destination interface{}, key []interface{}) Result Sismember(key, member interface{}) Result Smembers(key interface{}) Result Smove(source, destination, member interface{}) Result Spop(key interface{}, count *int64) Result Srandmember(key interface{}, count *int64) Result Srem(key interface{}, member []interface{}) Result Sscan(key interface{}, cursor int64, match *string, count *int64) Result Sunion(key []interface{}) Result Sunionstore(destination interface{}, key []interface{}) Result }
type Slice ¶
type Slice []RedisValue
A Slice represents the redis slice type.
func (Slice) ToInt64Slice ¶
ToInt64Slice returns a slice with values of type int64. In case value conversion to string is not possible a ConversitionError is returned.
func (Slice) ToSlice2 ¶
ToSlice2 returns a slice with values of type []interface{}. In case value conversion to []interface{} is not possible a ConversitionError is returned.
func (Slice) ToStringMap ¶
func (Slice) ToStringMapSlice ¶
ToStringMapSlice returns a slice with values of type map[string]interfcae{}. In case value conversion to map[string]interface{} is not possible a ConversitionError is returned.
func (Slice) ToStringSlice ¶
ToStringSlice returns a slice with values of type string. In case value conversion to string is not possible a ConversitionError is returned.
func (Slice) ToTree ¶
ToTree returns a tree with nodes of type []interface{} and leaves of type interface{}. In case value conversion to []interface{} is not possible a ConversitionError is returned.
type Slice2er ¶
type Slice2er interface { // ToSlice2 returns a slice with values of type []interface{}. In case value conversion to []interface{} is not possible // a ConversitionError is returned. ToSlice2() ([][]interface{}, error) }
Slice2er is implemented by any redis value that has a ToSlice2 method.
type Slicer ¶
type Slicer interface { // ToSlice returns a slice with values of type interface{}. ToSlice() ([]interface{}, error) }
Slicer is implemented by any redis value that has a ToSlice method.
type SortedSetCommands ¶
type SortedSetCommands interface { Bzpopmax(key []interface{}, timeout int64) Result Bzpopmin(key []interface{}, timeout int64) Result Zadd(key interface{}, scoreMember []ScoreMember) Result ZaddCh(key interface{}, scoreMember []ScoreMember) Result ZaddNx(key interface{}, scoreMember []ScoreMember) Result ZaddXx(key interface{}, scoreMember []ScoreMember) Result ZaddXxCh(key interface{}, scoreMember []ScoreMember) Result Zcard(key interface{}) Result Zcount(key interface{}, min, max Zfloat64) Result Zincrby(key interface{}, increment float64, member interface{}) Result Zinterstore(destination interface{}, numkeys int64, key []interface{}, weights []int64, aggregate *Aggregate) Result Zlexcount(key interface{}, min, max string) Result Zpopmax(key interface{}, count *int64) Result Zpopmin(key interface{}, count *int64) Result Zrange(key interface{}, start, stop int64, withscores bool) Result Zrangebylex(key interface{}, min, max string, limit *OffsetCount) Result Zrangebyscore(key interface{}, min, max Zfloat64, withscores bool, limit *OffsetCount) Result Zrank(key, member interface{}) Result Zrem(key interface{}, member []interface{}) Result Zremrangebylex(key interface{}, min, max string) Result Zremrangebyrank(key interface{}, start, stop int64) Result Zremrangebyscore(key interface{}, min, max Zfloat64) Result Zrevrange(key interface{}, start, stop int64, withscores bool) Result Zrevrangebylex(key interface{}, max, min string, limit *OffsetCount) Result Zrevrangebyscore(key interface{}, max, min Zfloat64, withscores bool, limit *OffsetCount) Result Zrevrank(key, member interface{}) Result Zscan(key interface{}, cursor int64, match *string, count *int64) Result Zscore(key, member interface{}) Result Zunionstore(destination interface{}, numkeys int64, key []interface{}, weights []int64, aggregate *Aggregate) Result }
type StartEndCount ¶
type StreamCommands ¶
type StreamCommands interface { Xack(key interface{}, group string, id []string) Result Xadd(key interface{}, id string, fieldValue []FieldValue) Result Xclaim(key interface{}, group, consumer, minIdleTime string, id []string, idle, time, retrycount *int64, force, justid bool) Result Xdel(key interface{}, id []string) Result XgroupCreate(key interface{}, groupname, id string, mkstream bool) Result XgroupDelconsumer(key interface{}, groupname, consumername string) Result XgroupDestroy(key interface{}, groupname string) Result XgroupHelp() Result XgroupSetid(key interface{}, groupname, id string) Result XinfoConsumers(key interface{}, groupname string) Result XinfoGroups(key interface{}) Result XinfoHelp() Result XinfoStream(key interface{}) Result Xlen(key interface{}) Result Xpending(key interface{}, group string, startEndCount *StartEndCount, consumer *string) Result Xrange(key interface{}, start, end string, count *int64) Result Xread(count, block *int64, key []interface{}, id []string) Result Xreadgroup(group GroupConsumer, count, block *int64, noack bool, key []interface{}, id []string) Result Xrevrange(key interface{}, end, start string, count *int64) Result Xtrim(key interface{}, approx bool, count int64) Result }
type StringCommands ¶
type StringCommands interface { Append(key, value interface{}) Result Bitcount(key interface{}, startEnd *StartEnd) Result Bitfield(key interface{}, operation []interface{}) Result BitopAnd(destkey interface{}, srckey []interface{}) Result BitopNot(destkey, srckey interface{}) Result BitopOr(destkey interface{}, srckey []interface{}) Result BitopXor(destkey interface{}, srckey []interface{}) Result Bitpos(key interface{}, bit int64, start, end *int64) Result Decr(key interface{}) Result Decrby(key interface{}, decrement int64) Result Get(key interface{}) Result Getbit(key interface{}, offset int64) Result Getrange(key interface{}, start, end int64) Result Getset(key, value interface{}) Result Incr(key interface{}) Result Incrby(key interface{}, increment int64) Result Incrbyfloat(key interface{}, increment float64) Result Mget(key []interface{}) Result Mset(keyValue []KeyValue) Result MsetNx(keyValue []KeyValue) Result Set(key, value interface{}) Result SetEx(key, value interface{}, seconds int64) Result SetExNx(key, value interface{}, seconds int64) Result SetExXx(key, value interface{}, seconds int64) Result SetNx(key, value interface{}) Result SetPx(key, value interface{}, milliseconds int64) Result SetPxNx(key, value interface{}, milliseconds int64) Result SetPxXx(key, value interface{}, milliseconds int64) Result SetXx(key, value interface{}) Result Setbit(key interface{}, offset, value int64) Result Setrange(key interface{}, offset int64, value interface{}) Result Strlen(key interface{}) Result }
type StringInt64Mapper ¶
type StringInt64Mapper interface { // ToStringInt64Map returns a map with keys of type string and values of type int64. In case key or value conversion is not possible // a ConvertionError is returned. ToStringInt64Map() (map[string]int64, error) }
StringInt64Mapper is implemented by any redis value that has a ToStringInt64Map method.
type StringMapSlicer ¶
type StringMapSlicer interface { // ToStringMapSlice returns a slice with values of type map[string]interfcae{}. In case value conversion to map[string]interface{} is not possible // a ConversitionError is returned. ToStringMapSlice() ([]map[string]interface{}, error) }
StringMapSlicer is implemented by any redis value that has a ToStringMapSlice method.
type StringMapper ¶
type StringMapper interface { // ToStringMap returns a map with keys of type string. In case key conversion to string is not possible // a ConvertionError is returned. ToStringMap() (map[string]interface{}, error) }
StringMapper is implemented by any redis value that has a ToStringMap method.
type StringSetter ¶
type StringSetter interface { // ToStringSet returns a map with keys of type string and boolean true values. In case key conversion to string is not possible // a ConvertionError is returned. ToStringSet() (map[string]bool, error) }
StringSetter is implemented by any redis value that has a ToStringSet method.
type StringSlicer ¶
type StringSlicer interface { // ToStringSlice returns a slice with values of type string. In case value conversion to string is not possible // a ConversitionError is returned. ToStringSlice() ([]string, error) }
StringSlicer is implemented by any redis value that has a ToStringSlice method.
type StringStringMapper ¶
type StringStringMapper interface { // ToStringStringMap returns a map with keys and values of type string. In case key or value conversion to string is not possible // a ConvertionError is returned. ToStringStringMap() (map[string]string, error) }
StringStringMapper is implemented by any redis value that has a ToStringStringMap method.
type Stringer ¶
type Stringer interface { // ToString converts a redis value to a string. // In case the conversion is not supported a ConversionError is returned. ToString() (string, error) }
Stringer is implemented by any redis value that has a ToString method.
type TraceCallback ¶
TraceCallback is the function type for the tracing callback function.
type TransactionsCommands ¶
type Treer ¶
type Treer interface { // ToTree returns a tree with nodes of type []interface{} and leaves of type interface{}. In case value conversion to []interface{} is not possible // a ConversitionError is returned. ToTree() ([]interface{}, error) }
Treer is implemented by any redis value that has a ToTree method.
type TypeOffset ¶
type TypeOffsetIncrement ¶
type TypeOffsetValue ¶
type UnexpectedCharacterError ¶
An UnexpectedCharacterError is raised by decoding an unexpected character.
func (*UnexpectedCharacterError) Error ¶
func (e *UnexpectedCharacterError) Error() string
type UserPassword ¶
type VerbatimString ¶
type VerbatimString string
A VerbatimString represents the redis verbatim string type.
func (VerbatimString) Attr ¶
func (s VerbatimString) Attr() *Map
func (VerbatimString) FileFormat ¶
func (s VerbatimString) FileFormat() string
FileFormat is returning the file format of a verbatim string.
func (VerbatimString) Kind ¶
func (s VerbatimString) Kind() RedisKind
Kind returns the type of a VerbatimString.
func (VerbatimString) String ¶
func (s VerbatimString) String() string
String implements the Stringer interface.
func (VerbatimString) ToBool ¶
func (s VerbatimString) ToBool() (bool, error)
ToBool implements the Converter ToBooler interface.
func (VerbatimString) ToFloat64 ¶
func (s VerbatimString) ToFloat64() (float64, error)
ToFloat64 implements the Converter ToFloat64er interface.
func (VerbatimString) ToInt64 ¶
func (s VerbatimString) ToInt64() (int64, error)
ToInt64 implements the Converter ToInt64er interface.
func (VerbatimString) ToInt64Slice ¶
func (s VerbatimString) ToInt64Slice() ([]int64, error)
func (VerbatimString) ToSlice ¶
func (s VerbatimString) ToSlice() ([]interface{}, error)
func (VerbatimString) ToSlice2 ¶
func (s VerbatimString) ToSlice2() ([][]interface{}, error)
func (VerbatimString) ToString ¶
func (s VerbatimString) ToString() (string, error)
ToString implements the Converter Stringer interface.
func (VerbatimString) ToStringInt64Map ¶
func (s VerbatimString) ToStringInt64Map() (map[string]int64, error)
func (VerbatimString) ToStringMap ¶
func (s VerbatimString) ToStringMap() (map[string]interface{}, error)
func (VerbatimString) ToStringMapSlice ¶
func (s VerbatimString) ToStringMapSlice() ([]map[string]interface{}, error)
func (VerbatimString) ToStringSet ¶
func (s VerbatimString) ToStringSet() (map[string]bool, error)
func (VerbatimString) ToStringSlice ¶
func (s VerbatimString) ToStringSlice() ([]string, error)
func (VerbatimString) ToStringStringMap ¶
func (s VerbatimString) ToStringStringMap() (map[string]string, error)
func (VerbatimString) ToTree ¶
func (s VerbatimString) ToTree() ([]interface{}, error)
func (VerbatimString) ToXrange ¶
func (s VerbatimString) ToXrange() ([]IDMap, error)
type Xranger ¶
type Xranger interface { // ToXrange returns a slice with values of type IdMap. In case the conversion is not possible // a ConversitionError is returned. ToXrange() ([]IDMap, error) }
Xranger is implemented by any redis value that has a ToXrange method.
type Xreader ¶
type Xreader interface { // ToXread returns a map[string] with values of type IdMap. In case the conversion is not possible // a ConversitionError is returned. ToXread() (map[string][]IDMap, error) }
Xreader is implemented by any redis value that has a ToXread method.