Documentation ¶
Index ¶
- Variables
- func Aggregator(aggregation Aggregation) func([]interface{}) (interface{}, error)
- func NewPool(poolConfig *PoolConfig, internalMaxActive int) *redis.Pool
- type Aggregation
- type ArgsExtractor
- type ArgsExtractorFunc
- type Cache
- type CacheEntryData
- type CacheEntrySetter
- type CacheEntryState
- type KeyTypeAggregation
- type LedisConn
- func (l *LedisConn) Close() error
- func (l *LedisConn) Do(commandName string, args ...interface{}) (interface{}, error)
- func (l *LedisConn) DoWithTimeout(timeout time.Duration, commandName string, args ...interface{}) (interface{}, error)
- func (l *LedisConn) Err() error
- func (l *LedisConn) Flush() error
- func (l *LedisConn) RawConn() redis.Conn
- func (l *LedisConn) Receive() (interface{}, error)
- func (l *LedisConn) ReceiveWithTimeout(timeout time.Duration) (interface{}, error)
- func (l *LedisConn) Send(commandName string, args ...interface{}) error
- type LedisType
- type PoolConfig
- type RedisCommand
- type RedisType
- type Resolver
- type Rewriter
- func (r *Rewriter) NewPool(config *PoolConfig) *redis.Pool
- func (r *Rewriter) NewPrimaryPool(config *PoolConfig, internalMaxActive int) *redis.Pool
- func (r *Rewriter) Resolver() Resolver
- func (r *Rewriter) Rewrite(commandName string, args ...interface{}) (SendLedisFunc, error)
- func (r *Rewriter) WrapConn(conn redis.Conn) *LedisConn
- type SendLedisFunc
- func LremCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func PingCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func RestoreCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func ScriptCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func SetCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func TransactionTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func UnsafeCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- func ZaddCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
- type Slot
- type SlotDeque
- func (q *SlotDeque) At(i int) Slot
- func (q *SlotDeque) Back() Slot
- func (q *SlotDeque) Clear()
- func (q *SlotDeque) Front() Slot
- func (q *SlotDeque) Len() int
- func (q *SlotDeque) PopBack() Slot
- func (q *SlotDeque) PopFront() Slot
- func (q *SlotDeque) PushBack(elem Slot)
- func (q *SlotDeque) PushFront(elem Slot)
- func (q *SlotDeque) Rotate(n int)
- type SubPool
- type TransformFunc
- type TypeInfo
- type TypeSpecificBulkTransformerConfig
- type TypeSpecificCommands
Constants ¶
This section is empty.
Variables ¶
var ( RedisCommandAPPEND = RedisCommand{ Name: "APPEND", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "APPEND key value", } RedisCommandBITCOUNT = RedisCommand{ Name: "BITCOUNT", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "BITCOUNT key [start end]", } // RedisCommandBITOP contains information about the BITOP Redis command. // BITOP writes the result of operation to destkey. However, it treats // unset keys as "\x00" * max(len key). I.e. the commands succeeds even if // some keys are not set. // // Perhaps KeyExtractor should be ArgsAtIndices(1) instead, as only // destkey is a string. // If no keys are set the result of applying the operation is a 0 length // string. In this case Redis sets destkey to nil (does not exist). // // TODO: Define the exact meaning of KeyType / KeyExtractor. RedisCommandBITOP = RedisCommand{ Name: "BITOP", KeyType: RedisTypeString, KeyExtractor: ArgsFromIndex(1), TransformFunc: NoneTransformer(), Syntax: "BITOP operation destkey key [key ...]", } RedisCommandBITPOS = RedisCommand{ Name: "BITPOS", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "BITPOS key bit [start] [end]", } RedisCommandDECR = RedisCommand{ Name: "DECR", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "DECR key", } RedisCommandDECRBY = RedisCommand{ Name: "DECRBY", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "DECRBY key decrement", } RedisCommandGET = RedisCommand{ Name: "GET", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "GET key", } RedisCommandGETBIT = RedisCommand{ Name: "GETBIT", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "GETBIT key offset", } RedisCommandGETRANGE = RedisCommand{ Name: "GETRANGE", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "GETRANGE key start end", } RedisCommandGETSET = RedisCommand{ Name: "GETSET", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "GETSET key value", } RedisCommandINCR = RedisCommand{ Name: "INCR", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "INCR key", } RedisCommandINCRBY = RedisCommand{ Name: "INCRBY", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "INCRBY key increment", } RedisCommandMGET = RedisCommand{ Name: "MGET", KeyType: RedisTypeString, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "MGET key [key ...]", } RedisCommandMSET = RedisCommand{ Name: "MSET", KeyType: RedisTypeString, KeyExtractor: ArgsFromIndex(0, 1), TransformFunc: NoneTransformer(), Syntax: "MSET key value [key value ...]", } RedisCommandSET = RedisCommand{ Name: "SET", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: SetCommandTransformer, Syntax: "SET key value [expiration EX seconds|PX milliseconds] [NX|XX]", } RedisCommandSETBIT = RedisCommand{ Name: "SETBIT", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SETBIT key offset value", } RedisCommandSETEX = RedisCommand{ Name: "SETEX", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SETEX key seconds value", } RedisCommandSETNX = RedisCommand{ Name: "SETNX", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SETNX key value", } RedisCommandSETRANGE = RedisCommand{ Name: "SETRANGE", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SETRANGE key offset value", } RedisCommandSTRLEN = RedisCommand{ Name: "STRLEN", KeyType: RedisTypeString, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "STRLEN key", } )
RedisCommand variables describing the Redis commands operating on strings (RedisTypeString).
https://redis.io/commands#string
var ( RedisCommandHDEL = RedisCommand{ Name: "HDEL", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HDEL key field [field ...]", } RedisCommandHEXISTS = RedisCommand{ Name: "HEXISTS", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HEXISTS key field", } RedisCommandHGET = RedisCommand{ Name: "HGET", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HGET key field", } RedisCommandHGETALL = RedisCommand{ Name: "HGETALL", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HGETALL key", } RedisCommandHINCRBY = RedisCommand{ Name: "HINCRBY", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HINCRBY key field increment", } RedisCommandHKEYS = RedisCommand{ Name: "HKEYS", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HKEYS key", } RedisCommandHLEN = RedisCommand{ Name: "HLEN", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HLEN key", } RedisCommandHMGET = RedisCommand{ Name: "HMGET", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HMGET key field [field ...]", } RedisCommandHMSET = RedisCommand{ Name: "HMSET", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HMSET key field value [field value ...]", } RedisCommandHSET = RedisCommand{ Name: "HSET", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HSET key field value", } RedisCommandHVALS = RedisCommand{ Name: "HVALS", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HVALS key", } RedisCommandHSCAN = RedisCommand{ Name: "HSCAN", KeyType: RedisTypeHash, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "HSCAN key cursor [MATCH pattern] [COUNT count]", } )
RedisCommand variables describing the Redis commands operating on hashes (RedisTypeHash).
https://redis.io/commands#hash
var ( RedisCommandBLPOP = RedisCommand{ Name: "BLPOP", KeyType: RedisTypeList, KeyExtractor: ArgsFromUntilIndex(0, -1), TransformFunc: NoneTransformer(), Syntax: "BLPOP key [key ...] timeout", } RedisCommandBRPOP = RedisCommand{ Name: "BRPOP", KeyType: RedisTypeList, KeyExtractor: ArgsFromUntilIndex(0, -1), TransformFunc: NoneTransformer(), Syntax: "BRPOP key [key ...] timeout", } RedisCommandBRPOPLPUSH = RedisCommand{ Name: "BRPOPLPUSH", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0, 1), TransformFunc: NoneTransformer(), Syntax: "BRPOPLPUSH source destination timeout", } RedisCommandLINDEX = RedisCommand{ Name: "LINDEX", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "LINDEX key index", } RedisCommandLLEN = RedisCommand{ Name: "LLEN", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "LLEN key index", } RedisCommandLPOP = RedisCommand{ Name: "LPOP", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "LPOP key", } RedisCommandLPUSH = RedisCommand{ Name: "LPUSH", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "LPUSH key value [value ...]", } RedisCommandLRANGE = RedisCommand{ Name: "LRANGE", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "LRANGE key start stop", } RedisCommandLREM = RedisCommand{ Name: "LREM", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: LremCommandTransformer, Syntax: "LREM key count value", } RedisCommandLTRIM = RedisCommand{ Name: "LTRIM", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "LTRIM key start stop", } RedisCommandRPOP = RedisCommand{ Name: "RPOP", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "RPOP key", } RedisCommandRPOPLPUSH = RedisCommand{ Name: "RPOPLPUSH", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0, 1), TransformFunc: NoneTransformer(), Syntax: "RPOPLPUSH source destination", } RedisCommandRPUSH = RedisCommand{ Name: "RPUSH", KeyType: RedisTypeList, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "RPUSH key value [value ...]", } )
RedisCommand variables describing the Redis commands operating on lists (RedisTypeList).
https://redis.io/commands#list
var ( RedisCommandSADD = RedisCommand{ Name: "SADD", KeyType: RedisTypeSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SADD key member [member ...]", } RedisCommandSCARD = RedisCommand{ Name: "SCARD", KeyType: RedisTypeSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SCARD key", } RedisCommandSDIFF = RedisCommand{ Name: "SDIFF", KeyType: RedisTypeSet, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "SDIFF key [key ...]", } RedisCommandSDIFFSTORE = RedisCommand{ Name: "SDIFFSTORE", KeyType: RedisTypeSet, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "SDIFFSTORE destination key [key ...]", } RedisCommandSINTER = RedisCommand{ Name: "SINTER", KeyType: RedisTypeSet, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "SINTER key [key ...]", } RedisCommandSINTERSTORE = RedisCommand{ Name: "SINTERSTORE", KeyType: RedisTypeSet, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "SINTERSTORE destination key [key ...]", } RedisCommandSISMEMBER = RedisCommand{ Name: "SISMEMBER", KeyType: RedisTypeSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SISMEMBER key member", } RedisCommandSMEMBERS = RedisCommand{ Name: "SMEMBERS", KeyType: RedisTypeSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SMEMBERS key", } RedisCommandSREM = RedisCommand{ Name: "SREM", KeyType: RedisTypeSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SREM key member [member ...]", } RedisCommandSSCAN = RedisCommand{ Name: "SSCAN", KeyType: RedisTypeSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "SSCAN key cursor [MATCH pattern] [COUNT count]", } RedisCommandSUNION = RedisCommand{ Name: "SUNION", KeyType: RedisTypeSet, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "SUNION key [key ...]", } RedisCommandSUNIONSTORE = RedisCommand{ Name: "SUNIONSTORE", KeyType: RedisTypeSet, KeyExtractor: ArgsFromIndex(0), TransformFunc: NoneTransformer(), Syntax: "SUNIONSTORE destination key [key ...]", } )
RedisCommand variables describing the Redis commands operating on sets (RedisTypeSet).
https://redis.io/commands#set
var ( RedisCommandZADD = RedisCommand{ Name: "ZADD", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: ZaddCommandTransformer, Syntax: "ZADD key [NX|XX] [CH] [INCR] score member [score member ...]", } RedisCommandZCARD = RedisCommand{ Name: "ZCARD", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZCARD key", } RedisCommandZCOUNT = RedisCommand{ Name: "ZCOUNT", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZCOUNT key min max", } RedisCommandZINCRBY = RedisCommand{ Name: "ZINCRBY", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZINCRBY key increment member", } // RedisCommandZINTERSTORE contains information about the ZINTERSTORE Redis // command. // // The KeyExtractor only extracts the destination key. Further keys could // be extracted by introducing a new KeyExtractor implementation. // However, Redis interprets non-existing key as empty keys. RedisCommandZINTERSTORE = RedisCommand{ Name: "ZINTERSTORE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]", } RedisCommandZLEXCOUNT = RedisCommand{ Name: "ZLEXCOUNT", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZLEXCOUNT key min max", } RedisCommandZRANGE = RedisCommand{ Name: "ZRANGE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZRANGE key start stop [WITHSCORES]", } RedisCommandZRANGEBYLEX = RedisCommand{ Name: "ZRANGEBYLEX", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZRANGEBYLEX key min max [LIMIT offset count]", } RedisCommandZRANGEBYSCORE = RedisCommand{ Name: "ZRANGEBYSCORE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]", } RedisCommandZRANK = RedisCommand{ Name: "ZRANK", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZRANK key member", } RedisCommandZREM = RedisCommand{ Name: "ZREM", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREM key member [member ...]", } RedisCommandZREMRANGEBYLEX = RedisCommand{ Name: "ZREMRANGEBYLEX", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREMRANGEBYLEX key min max", } RedisCommandZREMRANGEBYRANK = RedisCommand{ Name: "ZREMRANGEBYRANK", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREMRANGEBYRANK key start stop", } RedisCommandZREMRANGEBYSCORE = RedisCommand{ Name: "ZREMRANGEBYSCORE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREMRANGEBYSCORE key min max", } RedisCommandZREVRANGE = RedisCommand{ Name: "ZREVRANGE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREVRANGE key start stop [WITHSCORES]", } RedisCommandZREVRANGEBYSCORE = RedisCommand{ Name: "ZREVRANGEBYSCORE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]", } RedisCommandZREVRANK = RedisCommand{ Name: "ZREVRANK", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZREVRANK key member", } RedisCommandZSCAN = RedisCommand{ Name: "ZSCAN", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZSCAN key cursor [MATCH pattern] [COUNT count]", } RedisCommandZSCORE = RedisCommand{ Name: "ZSCORE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZSCORE key member", } // RedisCommandZUNIONSTORE contains information about the ZUNIONSTORE Redis // command. // // The KeyExtractor only extracts the destination key. Further keys could // be extracted by introducing a new KeyExtractor implementation. // However, Redis interprets non-existing key as empty keys. RedisCommandZUNIONSTORE = RedisCommand{ Name: "ZUNIONSTORE", KeyType: RedisTypeZSet, KeyExtractor: ArgsAtIndices(0), TransformFunc: NoneTransformer(), Syntax: "ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]", } )
RedisCommand variables describing the Redis commands operating on sorted sets (RedisTypeZSet).
https://redis.io/commands#sorted_set
var ( RedisCommandDEL = RedisCommand{ Name: "DEL", KeyType: RedisTypeGeneric, KeyExtractor: ArgsFromIndex(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "DEL", List: "LMCLEAR", Hash: "HMCLEAR", Set: "SMCLEAR", ZSet: "ZMCLEAR", }, Aggregation: AggregationSum, }), Syntax: "DEL key [key ...]", } RedisCommandDUMP = RedisCommand{ Name: "DUMP", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "DUMP", List: "LDUMP", Hash: "HDUMP", Set: "SDUMP", ZSet: "ZDUMP", }, Aggregation: AggregationFirst, }), Syntax: "DUMP key", } RedisCommandEXISTS = RedisCommand{ Name: "EXISTS", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "EXISTS", List: "LKEYEXISTS", Hash: "HKEYEXISTS", Set: "SKEYEXISTS", ZSet: "ZKEYEXISTS", }, Debulk: true, Aggregation: AggregationSum, }), Syntax: "EXISTS key [key ...]", } RedisCommandEXPIRE = RedisCommand{ Name: "EXPIRE", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "EXPIRE", List: "LEXPIRE", Hash: "HEXPIRE", Set: "SEXPIRE", ZSet: "ZEXPIRE", }, Aggregation: AggregationSum, AppendArgsExtractor: ArgsAtIndices(1), }), Syntax: "EXPIRE key seconds", } RedisCommandEXPIREAT = RedisCommand{ Name: "EXPIREAT", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "EXPIREAT", List: "LEXPIREAT", Hash: "HEXPIREAT", Set: "SEXPIREAT", ZSet: "ZEXPIREAT", }, Aggregation: AggregationSum, AppendArgsExtractor: ArgsAtIndices(1), }), Syntax: "EXPIREAT key timestamp", } RedisCommandPERSIST = RedisCommand{ Name: "PERSIST", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "PERSIST", List: "LPERSIST", Hash: "HPERSIST", Set: "SPERSIST", ZSet: "ZPERSIST", }, Aggregation: AggregationSum, }), Syntax: "PERSIST key", } RedisCommandRESTORE = RedisCommand{ Name: "RESTORE", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: RestoreCommandTransformer, Syntax: "RESTORE key ttl serialized-value [REPLACE] [ABSTTL] [IDLETIME seconds] [FREQ frequency]", } RedisCommandSORT = RedisCommand{ Name: "SORT", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ List: "XLSORT", Set: "XSSORT", ZSet: "XZSORT", }, Aggregation: AggregationFirst, }), Syntax: "SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]", } RedisCommandTTL = RedisCommand{ Name: "TTL", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TypeSpecificBulkTransformer(&TypeSpecificBulkTransformerConfig{ Commands: TypeSpecificCommands{ KV: "TTL", List: "LTTL", Hash: "HTTL", Set: "STTL", ZSet: "ZTTL", }, Aggregation: AggregationSum, }), Syntax: "TTL key", } )
RedisCommand variables describing the Redis commands operating on keys / generics (RedisTypeGeneric).
https://redis.io/commands#generic
var ( RedisCommandDISCARD = RedisCommand{ Name: "DISCARD", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TransactionTransformer, Syntax: "DISCARD", } RedisCommandEXEC = RedisCommand{ Name: "EXEC", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TransactionTransformer, Syntax: "EXEC", } RedisCommandMULTI = RedisCommand{ Name: "MULTI", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TransactionTransformer, Syntax: "MULTI", } RedisCommandUNWATCH = RedisCommand{ Name: "UNWATCH", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(0), TransformFunc: TransactionTransformer, Syntax: "UNWATCH", } RedisCommandWATCH = RedisCommand{ Name: "WATCH", KeyType: RedisTypeGeneric, KeyExtractor: ArgsFromIndex(0), TransformFunc: TransactionTransformer, Syntax: "WATCH key [key ...]", } )
RedisCommand variables describing the Redis commands for performing transactions.
https://redis.io/commands#transactions
var ( RedisCommandAUTH = RedisCommand{ Name: "AUTH", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: NoneTransformer(), Syntax: "AUTH password", } RedisCommandECHO = RedisCommand{ Name: "ECHO", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: NoneTransformer(), Syntax: "ECHO message", } RedisCommandPING = RedisCommand{ Name: "PING", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: PingCommandTransformer, Syntax: "PING [message]", } RedisCommandSELECT = RedisCommand{ Name: "SELECT", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: NoneTransformer(), Syntax: "SELECT index", } )
RedisCommand variables describing the Redis commands for managing the connection: Utilities for probing and altering connection properties.
https://redis.io/commands#connection
var ( RedisCommandEVAL = RedisCommand{ Name: "EVAL", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: NoneTransformer(), Syntax: "EVAL script numkeys key [key ...] arg [arg ...]", } RedisCommandEVALSHA = RedisCommand{ Name: "EVALSHA", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: NoneTransformer(), Syntax: "EVALSHA sha1 numkeys key [key ...] arg [arg ...]", } RedisCommandSCRIPT = RedisCommand{ Name: "SCRIPT", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: ScriptCommandTransformer, Syntax: "SCRIPT subcommand [arg ...]", } )
RedisCommand variables describing the Redis commands for working with lua scripts.
https://redis.io/commands#scripting
var ( ErrUnknownLedisTypeString = errors.New("input string does not represent a known LedisType value") ErrInvalidLedisType = errors.New("input LedisType value is unknown or otherwise invalid for this operation") ErrNoCorrespondingLedisType = errors.New("there is no LedisType value corresponding to the input RedisType value") )
var ( ErrUnknownRedisTypeString = errors.New("input string does not represent a known RedisType value") ErrInvalidRedisType = errors.New("input RedisType value is unknown or otherwise invalid for this operation") )
var ( ErrTimeoutNotSupported = errors.New("rewledis: connection does not support ConnWithTimeout") ErrConnClosed = errors.New("rewledis: connection closed") )
Error variables related to the LedisConn type.
var ( ErrUnexpectedCacheEntryState = errors.New("encountered cache entry with unexpected state") ErrErrorCacheEntryState = errors.New("encountered cache entry with Error state") )
Error variables related to Resolver.
var ( ErrSubCommandNotImplemented = errors.New("sub command not implemented") ErrSubCommandUnknown = errors.New("sub command unknown") ErrInvalidArgumentCombination = errors.New("invalid argument combination") ErrInvalidSyntax = errors.New("invalid syntax") ErrInvalidArgumentType = errors.New("invalid argument type") ErrNoEmulationPossible = errors.New("no emulation possible for the issued command") )
Error variables related to transformers.
var (
ErrInvalidAggregationValue = errors.New("invalid Aggregation value")
)
var (
ErrUnknownRedisCommandName = errors.New("input string does not represent a known RedisCommand name")
)
var (
ErrUnsupportedSubPoolConnection = errors.New("connection returned by SubPool is unsupported by this operation")
)
Error variables related to SubPool.
var ( RedisCommandUNSAFE = RedisCommand{ Name: "UNSAFE", KeyType: RedisTypeGeneric, KeyExtractor: ArgsAtIndices(), TransformFunc: UnsafeCommandTransformer, Syntax: "UNSAFE subcommand [arg ...]", } )
RedisCommand variable describing the rewledis specific UNSAFE command. Similarly to the homonymous Go package: Do not use this unless you know what you are doing.
Functions ¶
func Aggregator ¶
func Aggregator(aggregation Aggregation) func([]interface{}) (interface{}, error)
Aggregator creates an aggregator, i.e. a function which reduces any number of reply values to a single reply value.
Types ¶
type Aggregation ¶
type Aggregation int8
const ( AggregationSum Aggregation = iota AggregationCountOne AggregationFirst )
type ArgsExtractor ¶
type ArgsExtractor interface { AppendArgs(extracted []interface{}, args []interface{}) []interface{} Args(args []interface{}) []interface{} }
func ArgsAtIndices ¶
func ArgsAtIndices(indices ...int) ArgsExtractor
ArgsAtIndices returns an ArgsExtractor. The ArgsExtractor returns the arguments with the indices passed to ArgsAtIndices.
func ArgsFromIndex ¶
func ArgsFromIndex(index int, skip ...int) ArgsExtractor
ArgsFromIndex returns an ArgsExtractor. The ArgsExtractor returns all arguments starting at the index passed as a parameter. If the optional parameter skip is passed, skip arguments are skipped after each key argument.
func ArgsFromUntilIndex ¶
func ArgsFromUntilIndex(from, until int, skip ...int) ArgsExtractor
ArgsFromIndexUntil returns an ArgsExtractor. The ArgsExtractor returns all arguments between the two indices passed as parameters, including the argument at from and excluding the argument at until. It works in the same way as slice ranges: args[from:until].
If until is 0 the maximum possible value is presumed. If until is less than 0 it is subtracted from the length of the arguments.
If the optional parameter skip is passed, skip arguments are skipped after each key argument.
type ArgsExtractorFunc ¶
type ArgsExtractorFunc func(extracted []interface{}, args []interface{}) []interface{}
func (ArgsExtractorFunc) AppendArgs ¶
func (a ArgsExtractorFunc) AppendArgs(extracted []interface{}, args []interface{}) []interface{}
func (ArgsExtractorFunc) Args ¶
func (a ArgsExtractorFunc) Args(args []interface{}) []interface{}
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) LoadOrCreateEntry ¶
func (c *Cache) LoadOrCreateEntry(key string) (CacheEntryData, CacheEntrySetter, bool)
LoadOrCreateEntry is the primary access method for the cache. For a given key, it returns either entry data or a setter. If a setter is returned, the caller must fulfill the setter by calling .Set().
The bool returned indicates whether the entry exists and is in the Loading or Exists state (this means the returned CacheEntryData is valid). If the bool is false, the returned CacheEntrySetter is valid.
func (*Cache) TrySetEntry ¶
func (c *Cache) TrySetEntry(key string, state CacheEntryState, keyType LedisType) bool
TrySetEntry tries to update the entry for the given key with given state and keyType information. TrySetEntry does not wait for an ongoing loading procedure and returns without setting in this case. TrySetEntry returns true, if the entry was updated and false if not.
type CacheEntryData ¶
type CacheEntryData struct { WrittenAt time.Time Key string DoneLoading <-chan struct{} State CacheEntryState Type LedisType // contains filtered or unexported fields }
func (*CacheEntryData) Refresh ¶
func (c *CacheEntryData) Refresh()
type CacheEntrySetter ¶
type CacheEntrySetter struct { Key string // contains filtered or unexported fields }
func (*CacheEntrySetter) Set ¶
func (c *CacheEntrySetter) Set(state CacheEntryState, keyType LedisType)
Set sets the Type field of an entry along with the State and WrittenAt fields. It also signals completion of the loading process by closing the DoneLoading channel. state must be either CacheEntryStateExists, CacheEntryStateDeleted or CacheEntryStateError and indicates the success state of the type resolution. If state is not CacheEntryStateExists the keyType value is ignored.
type CacheEntryState ¶
type CacheEntryState int8
const ( CacheEntryStateNone CacheEntryState = iota CacheEntryStateLoading CacheEntryStateExists CacheEntryStateDeleted CacheEntryStateError )
Constants which a CacheEntryState value can assume.
type KeyTypeAggregation ¶
type KeyTypeAggregation struct { None []string KV []string List []string Hash []string Set []string ZSet []string }
func (*KeyTypeAggregation) AppendKeys ¶
func (k *KeyTypeAggregation) AppendKeys(typesInfo []TypeInfo)
type LedisConn ¶
type LedisConn struct {
// contains filtered or unexported fields
}
LedisConn is a rewriting wrapper around a connection to a LedisDB server. Many Redis commands can be issued on this connection. The commands are dynamically rewritten to their LedisDB equivalent. See the repository's README for more information on which commands are supported.
func (*LedisConn) DoWithTimeout ¶
func (l *LedisConn) DoWithTimeout(timeout time.Duration, commandName string, args ...interface{}) (interface{}, error)
Do sends a command to the server and returns the received reply. The timeout overrides the read timeout set when dialing the connection.
func (*LedisConn) RawConn ¶
RawConn returns the underlying connection to the LedisDB server.
This method must be used with care, as the stack of internally stored reply procedures (Slots) can no longer be maintained. RawConn should only be used on connections without any pending replies.
func (*LedisConn) ReceiveWithTimeout ¶
Receive receives a single reply from the Redis server. The timeout overrides the read timeout set when dialing the connection.
type LedisType ¶
type LedisType int8
func LedisTypeFromRedisType ¶
func ParseLedisType ¶
func ParseLedisTypeFromLedis ¶
type PoolConfig ¶
type PoolConfig struct { // Dial is an application supplied function for creating and configuring a // connection. Dial must return a connection to a LedisDB server. Dial func() (redis.Conn, error) // TestOnBorrow is an optional application supplied function for checking the // health of an idle connection before the connection is used again by the // application. Argument c is a wrapped (rewriting) connection emulating // Redis semantics. Argument t is the time that the connection was returned // to the pool. If the function returns an error, then the connection is // closed. TestOnBorrow func(c redis.Conn, t time.Time) error // Maximum number of idle connections in the pool. MaxIdle int // MaxActive is the 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. MaxActive int // IdleTimeout is the duration after which to close idle connections. If // the value is zero, then idle connections are not closed. Applications // should set the timeout to a value less than the server's timeout. IdleTimeout time.Duration // If Wait is true and the pool is at the MaxActive limit, then Get() waits // for a connection to be returned to the pool before returning. Wait bool // Close connections older than this duration. If the value is zero, then // the pool does not close connections based on age. MaxConnLifetime time.Duration }
PoolConfig contains all configuration options for a redigo pool instance. The fields contained mirror the redis.Pool type of redigo.
func (*PoolConfig) Clone ¶
func (p *PoolConfig) Clone() *PoolConfig
func (*PoolConfig) CopyFrom ¶
func (p *PoolConfig) CopyFrom(other *PoolConfig)
func (*PoolConfig) Merge ¶
func (p *PoolConfig) Merge(other *PoolConfig) *PoolConfig
type RedisCommand ¶
type RedisCommand struct { Name string KeyType RedisType KeyExtractor ArgsExtractor TransformFunc TransformFunc Syntax string }
func RedisCommandFromName ¶
func RedisCommandFromName(name string) (*RedisCommand, error)
func (RedisCommand) AppendKeys ¶
func (r RedisCommand) AppendKeys(keys []string, args []interface{}) []string
func (RedisCommand) Keys ¶
func (r RedisCommand) Keys(args []interface{}) []string
type Resolver ¶
Resolver provides functionality to resolve the type of keys while using a Cache instance.
func (*Resolver) ResolveAppend ¶
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
func (*Rewriter) NewPool ¶
func (r *Rewriter) NewPool(config *PoolConfig) *redis.Pool
NewPool creates and returns a new Pool of connections to a LedisDB server. The returned Pool yields wrapped connections emulating Redis semantics. Commands are rewritten using this Rewriter.
In order for rewriting to work properly, the primary pool of the Rewriter must have been set. That means NewPrimaryPool has to have been called.
func (*Rewriter) NewPrimaryPool ¶
func (r *Rewriter) NewPrimaryPool(config *PoolConfig, internalMaxActive int) *redis.Pool
NewPrimaryPool creates a new pool from config and uses the created pool as its primary pool. The primary pool is used for internal operations, at the moment only by a Resolver. Use internalMaxActive to set the maximum number of connections used for internal purposes. 0 means no limit.
The primary pool is not changed if the primary pool of the Rewriter has already been set and this method is called again.
The returned Pool yields wrapped connections emulating Redis semantics. Commands are rewritten using this Rewriter.
func (*Rewriter) Resolver ¶
Resolver constructs and returns a Resolver instance using this rewriter.
type SendLedisFunc ¶
func LremCommandTransformer ¶
func LremCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
func PingCommandTransformer ¶
func PingCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
PingCommandTransformer performs transformations for the PING Redis command.
func RestoreCommandTransformer ¶
func RestoreCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
RestoreCommandTransformer performs transformations for the RESTORE Redis command.
The IDLETIME and FREQ modifiers are ignored and removed when passing on the command to LedisDB.
TODO: Figure out how LedisDB performs RESTORE and incorporate into REPLACE handling.
func ScriptCommandTransformer ¶
func ScriptCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
ScriptCommandTransformer performs transformations for the SCRIPT Redis command.
Only some sub-commands are supported. Issuing a not supported sub-command results in a ErrSubCommandNotImplemented error.
Implemented: SCRIPT EXISTS sha1 [sha1 ...] SCRIPT FLUSH SCRIPT LOAD script Not implemented: SCRIPT DEBUG YES|SYNC|NO SCRIPT KILL
func SetCommandTransformer ¶
func SetCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
SetCommandTransformer performs transformations for the SET Redis command.
This transformer mirrors Redis behaviour: When both XX and EX is supplied, nil is returned without applying any changes. When both EX and PX is supplied, the PX value takes precedence.
func TransactionTransformer ¶
func TransactionTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
TransactionTransformer performs transformations for transaction related Redis commands.
Support for transaction commands has not yet been integrated into rewledis. The transformer drops all commands except DISCARD for which ErrNoEmulationPossible is returned. This "emulation" is subject to race-conditions.
func UnsafeCommandTransformer ¶
func UnsafeCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
UnsafeCommandTransformer performs transformations for the UNSAFE Redis command provided by rewledis.
func ZaddCommandTransformer ¶
func ZaddCommandTransformer(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
type SlotDeque ¶
type SlotDeque struct {
// contains filtered or unexported fields
}
SlotDeque represents a single instance of the deque data structure.
func (*SlotDeque) At ¶
At returns the element at index i in the queue without removing the element from the queue. This method accepts only non-negative index values. At(0) refers to the first element and is the same as Front(). At(Len()-1) refers to the last element and is the same as Back(). If the index is invalid, the call panics.
The purpose of At is to allow SlotDeque to serve as a more general purpose circular buffer, where items are only added to and removed from the ends of the deque, but may be read from any place within the deque. Consider the case of a fixed-size circular log buffer: A new entry is pushed onto one end and when full the oldest is popped from the other end. All the log entries in the buffer must be readable without altering the buffer contents.
func (*SlotDeque) Back ¶
Back returns the element at the back of the queue. This is the element that would be returned by PopBack(). This call panics if the queue is empty.
func (*SlotDeque) Clear ¶
func (q *SlotDeque) Clear()
Clear removes all elements from the queue, but retains the current capacity. This is useful when repeatedly reusing the queue at high frequency to avoid GC during reuse. The queue will not be resized smaller as long as items are only added. Only when items are removed is the queue subject to getting resized smaller.
func (*SlotDeque) Front ¶
Front returns the element at the front of the queue. This is the element that would be returned by PopFront(). This call panics if the queue is empty.
func (*SlotDeque) PopBack ¶
PopBack removes and returns the element from the back of the queue. Implements LIFO when used with PushBack(). If the queue is empty, the call panics.
func (*SlotDeque) PopFront ¶
PopFront removes and returns the element from the front of the queue. Implements FIFO when used with PushBack(). If the queue is empty, the call panics.
func (*SlotDeque) PushBack ¶
PushBack appends an element to the back of the queue. Implements FIFO when elements are removed with PopFront(), and LIFO when elements are removed with PopBack().
type SubPool ¶
SubPool represents a fixed-capacity part of an existing redis.Pool. The SubPool allows a maximum of MaxActive connections to be in use by its consumers at any point in time.
The type mimics redis.Pool behaviour and should be initialised using struct initialisation.
subPool := SubPool{ Pool: pool, MaxActive: 5, }
Close() and further methods are purposefully omitted, the underlying redis.Pool is considered the owner and manager of the connection resources.
type TransformFunc ¶
type TransformFunc func(rewriter *Rewriter, command *RedisCommand, args []interface{}) (SendLedisFunc, error)
func NoneTransformer ¶
func NoneTransformer() TransformFunc
func TypeSpecificBulkTransformer ¶
func TypeSpecificBulkTransformer(config *TypeSpecificBulkTransformerConfig) TransformFunc
type TypeSpecificBulkTransformerConfig ¶
type TypeSpecificBulkTransformerConfig struct { Commands TypeSpecificCommands Debulk bool Aggregation Aggregation AppendArgsExtractor ArgsExtractor }