Documentation ¶
Index ¶
- type BIT
- func (b *BIT) BitCount(key string, offsetFrom int64, offsetTo int64) (valCount int64, err error)
- func (b *BIT) BitField(key string, args ...interface{}) (valBits []int64, err error)
- func (b *BIT) BitOp(keyDest string, bitOpType redisbitop.RedisBitop, keySource ...string) error
- func (b *BIT) BitPos(key string, bitValue int64, startPosition ...int64) (valPosition int64, err error)
- func (b *BIT) GetBit(key string, offset int64) (val int, err error)
- func (b *BIT) SetBit(key string, offset int64, bitValue bool) error
- type GEO
- func (g *GEO) GeoAdd(key string, geoLocation *redis.GeoLocation) error
- func (g *GEO) GeoDist(key string, member1 string, member2 string, ...) (valDist float64, notFound bool, err error)
- func (g *GEO) GeoHash(key string, member ...string) (geoHashSlice []string, notFound bool, err error)
- func (g *GEO) GeoPos(key string, member ...string) (*redis.GeoPosCmd, error)
- func (g *GEO) GeoRadius(key string, longitude float64, latitude float64, query *redis.GeoRadiusQuery) (*redis.GeoLocationCmd, error)
- func (g *GEO) GeoRadiusByMember(key string, member string, query *redis.GeoRadiusQuery) (*redis.GeoLocationCmd, error)
- func (g *GEO) GeoRadiusByMemberStore(key string, member string, query *redis.GeoRadiusQuery) error
- func (g *GEO) GeoRadiusStore(key string, longitude float64, latitude float64, query *redis.GeoRadiusQuery) error
- type HASH
- func (h *HASH) HDel(key string, field ...string) (deletedCount int64, err error)
- func (h *HASH) HExists(key string, field string) (valExists bool, err error)
- func (h *HASH) HGet(key string, field string, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (h *HASH) HGetAll(key string) (outputMap map[string]string, notFound bool, err error)
- func (h *HASH) HIncrBy(key string, field string, incrValue int64) error
- func (h *HASH) HIncrByFloat(key string, field string, incrValue float64) error
- func (h *HASH) HKeys(key string) (outputSlice []string, notFound bool, err error)
- func (h *HASH) HLen(key string) (valLen int64, notFound bool, err error)
- func (h *HASH) HMGet(key string, field ...string) (outputSlice []interface{}, notFound bool, err error)
- func (h *HASH) HMSet(key string, value ...interface{}) error
- func (h *HASH) HScan(key string, cursor uint64, match string, count int64) (outputKeys []string, outputCursor uint64, err error)
- func (h *HASH) HSet(key string, value ...interface{}) error
- func (h *HASH) HSetNX(key string, field string, value interface{}) error
- func (h *HASH) HVals(key string) (outputSlice []string, notFound bool, err error)
- type LIST
- func (l *LIST) LIndex(key string, index int64, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (l *LIST) LInsert(key string, bBefore bool, pivot interface{}, value interface{}) error
- func (l *LIST) LLen(key string) (val int64, notFound bool, err error)
- func (l *LIST) LPop(key string, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (l *LIST) LPush(key string, keyMustExist bool, value ...interface{}) error
- func (l *LIST) LRange(key string, start int64, stop int64) (outputSlice []string, notFound bool, err error)
- func (l *LIST) LRem(key string, count int64, value interface{}) error
- func (l *LIST) LSet(key string, index int64, value interface{}) error
- func (l *LIST) LTrim(key string, start int64, stop int64) error
- func (l *LIST) RPop(key string, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (l *LIST) RPopLPush(keySource string, keyDest string, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (l *LIST) RPush(key string, keyMustExist bool, value ...interface{}) error
- type PIPELINE
- type PUBSUB
- func (ps *PUBSUB) PSubscribe(channel ...string) (*redis.PubSub, error)
- func (ps *PUBSUB) PubSubChannels(pattern string) (valChannels []string, err error)
- func (ps *PUBSUB) PubSubNumPat() (valPatterns int64, err error)
- func (ps *PUBSUB) PubSubNumSub(channel ...string) (val map[string]int64, err error)
- func (ps *PUBSUB) Publish(channel string, message interface{}) (valReceived int64, err error)
- func (ps *PUBSUB) Subscribe(channel ...string) (*redis.PubSub, error)
- type Redis
- func (r *Redis) Append(key string, valToAppend string) error
- func (r *Redis) Connect() error
- func (r *Redis) Del(key ...string) (deletedCount int64, err error)
- func (r *Redis) Disconnect()
- func (r *Redis) Exists(key ...string) (foundCount int64, err error)
- func (r *Redis) Float64AddOrReduce(key string, val float64) (newVal float64, notFound bool, err error)
- func (r *Redis) Get(key string) (val string, notFound bool, err error)
- func (r *Redis) GetBase(key string) (cmd *redis.StringCmd, notFound bool, err error)
- func (r *Redis) GetBool(key string) (val bool, notFound bool, err error)
- func (r *Redis) GetBytes(key string) (val []byte, notFound bool, err error)
- func (r *Redis) GetFloat64(key string) (val float64, notFound bool, err error)
- func (r *Redis) GetInt(key string) (val int, notFound bool, err error)
- func (r *Redis) GetInt64(key string) (val int64, notFound bool, err error)
- func (r *Redis) GetJson(key string, resultObjectPtr interface{}) (notFound bool, err error)
- func (r *Redis) GetRange(key string, start int64, end int64) (val string, notFound bool, err error)
- func (r *Redis) GetSet(key string, val string) (oldValue string, notFound bool, err error)
- func (r *Redis) GetTime(key string) (val time.Time, notFound bool, err error)
- func (r *Redis) Int64AddOrReduce(key string, val int64, isReduce ...bool) (newVal int64, notFound bool, err error)
- func (r *Redis) MGet(key ...string) (results []interface{}, notFound bool, err error)
- func (r *Redis) MSet(kvMap map[string]interface{}, setIfNotExists ...bool) error
- func (r *Redis) PFAdd(key string, elements ...interface{}) error
- func (r *Redis) PFCount(key ...string) (val int64, notFound bool, err error)
- func (r *Redis) PFMerge(destKey string, sourceKey ...string) error
- func (r *Redis) Set(key string, val string, expires ...time.Duration) error
- func (r *Redis) SetBase(key string, val interface{}, setCondition redissetcondition.RedisSetCondition, ...) error
- func (r *Redis) SetBool(key string, val bool, expires ...time.Duration) error
- func (r *Redis) SetBytes(key string, val []byte, expires ...time.Duration) error
- func (r *Redis) SetFloat64(key string, val float64, expires ...time.Duration) error
- func (r *Redis) SetInt(key string, val int, expires ...time.Duration) error
- func (r *Redis) SetInt64(key string, val int64, expires ...time.Duration) error
- func (r *Redis) SetJson(key string, jsonObject interface{}, expires ...time.Duration) error
- func (r *Redis) SetRange(key string, offset int64, val string) error
- func (r *Redis) SetTime(key string, val time.Time, expires ...time.Duration) error
- func (r *Redis) StrLen(key string) (length int64, notFound bool, err error)
- func (r *Redis) Unlink(key ...string) (unlinkedCount int64, err error)
- type SET
- func (s *SET) SAdd(key string, member ...interface{}) error
- func (s *SET) SCard(key string) (val int64, notFound bool, err error)
- func (s *SET) SDiff(key ...string) (outputSlice []string, notFound bool, err error)
- func (s *SET) SDiffStore(keyDest string, keySource ...string) error
- func (s *SET) SInter(key ...string) (outputSlice []string, notFound bool, err error)
- func (s *SET) SInterStore(keyDest string, keySource ...string) error
- func (s *SET) SIsMember(key string, member interface{}) (val bool, err error)
- func (s *SET) SMembers(key string) (outputSlice []string, notFound bool, err error)
- func (s *SET) SMembersMap(key string) (outputMap map[string]struct{}, notFound bool, err error)
- func (s *SET) SMove(keySource string, keyDest string, member interface{}) error
- func (s *SET) SPop(key string, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (s *SET) SPopN(key string, count int64) (outputSlice []string, notFound bool, err error)
- func (s *SET) SRandMember(key string, outputDataType redisdatatype.RedisDataType, ...) (notFound bool, err error)
- func (s *SET) SRandMemberN(key string, count int64) (outputSlice []string, notFound bool, err error)
- func (s *SET) SRem(key string, member ...interface{}) error
- func (s *SET) SScan(key string, cursor uint64, match string, count int64) (outputKeys []string, outputCursor uint64, err error)
- func (s *SET) SUnion(key ...string) (outputSlice []string, notFound bool, err error)
- func (s *SET) SUnionStore(keyDest string, keySource ...string) error
- type SORTED_SET
- func (z *SORTED_SET) ZAdd(key string, setCondition redissetcondition.RedisSetCondition, getChanged bool, ...) error
- func (z *SORTED_SET) ZCard(key string) (val int64, notFound bool, err error)
- func (z *SORTED_SET) ZCount(key string, min string, max string) (val int64, notFound bool, err error)
- func (z *SORTED_SET) ZIncr(key string, setCondition redissetcondition.RedisSetCondition, member *redis.Z) error
- func (z *SORTED_SET) ZIncrBy(key string, increment float64, member string) error
- func (z *SORTED_SET) ZInterStore(keyDest string, store *redis.ZStore) error
- func (z *SORTED_SET) ZLexCount(key string, min string, max string) (val int64, notFound bool, err error)
- func (z *SORTED_SET) ZPopMax(key string, count ...int64) (outputSlice []redis.Z, notFound bool, err error)
- func (z *SORTED_SET) ZPopMin(key string, count ...int64) (outputSlice []redis.Z, notFound bool, err error)
- func (z *SORTED_SET) ZRange(key string, start int64, stop int64) (outputSlice []string, notFound bool, err error)
- func (z *SORTED_SET) ZRangeByLex(key string, opt *redis.ZRangeBy) (outputSlice []string, notFound bool, err error)
- func (z *SORTED_SET) ZRangeByScore(key string, opt *redis.ZRangeBy) (outputSlice []string, notFound bool, err error)
- func (z *SORTED_SET) ZRangeByScoreWithScores(key string, opt *redis.ZRangeBy) (outputSlice []redis.Z, notFound bool, err error)
- func (z *SORTED_SET) ZRank(key string, member string) (val int64, notFound bool, err error)
- func (z *SORTED_SET) ZRem(key string, member ...interface{}) error
- func (z *SORTED_SET) ZRemRangeByLex(key string, min string, max string) error
- func (z *SORTED_SET) ZRemRangeByRank(key string, start int64, stop int64) error
- func (z *SORTED_SET) ZRemRangeByScore(key string, min string, max string) error
- func (z *SORTED_SET) ZRevRange(key string, start int64, stop int64) (outputSlice []string, notFound bool, err error)
- func (z *SORTED_SET) ZRevRangeByScoreWithScores(key string, opt *redis.ZRangeBy) (outputSlice []redis.Z, notFound bool, err error)
- func (z *SORTED_SET) ZRevRangeWithScores(key string, start int64, stop int64) (outputSlice []redis.Z, notFound bool, err error)
- func (z *SORTED_SET) ZRevRank(key string, member string) (val int64, notFound bool, err error)
- func (z *SORTED_SET) ZScan(key string, cursor uint64, match string, count int64) (outputKeys []string, outputCursor uint64, err error)
- func (z *SORTED_SET) ZScore(key string, member string) (val float64, notFound bool, err error)
- func (z *SORTED_SET) ZUnionStore(keyDest string, store *redis.ZStore) error
- type STREAM
- func (x *STREAM) XAck(stream string, group string, id ...string) error
- func (x *STREAM) XAdd(addArgs *redis.XAddArgs) error
- func (x *STREAM) XClaim(claimArgs *redis.XClaimArgs) (valMessages []redis.XMessage, notFound bool, err error)
- func (x *STREAM) XClaimJustID(claimArgs *redis.XClaimArgs) (outputSlice []string, notFound bool, err error)
- func (x *STREAM) XDel(stream string, id ...string) error
- func (x *STREAM) XGroupCreate(stream string, group string, start string) error
- func (x *STREAM) XGroupCreateMkStream(stream string, group string, start string) error
- func (x *STREAM) XGroupDelConsumer(stream string, group string, consumer string) error
- func (x *STREAM) XGroupDestroy(stream string, group string) error
- func (x *STREAM) XGroupSetID(stream string, group string, start string) error
- func (x *STREAM) XInfoGroups(key string) (outputSlice []redis.XInfoGroups, notFound bool, err error)
- func (x *STREAM) XLen(stream string) (val int64, notFound bool, err error)
- func (x *STREAM) XPending(stream string, group string) (val *redis.XPending, notFound bool, err error)
- func (x *STREAM) XPendingExt(pendingArgs *redis.XPendingExtArgs) (outputSlice []redis.XPendingExt, notFound bool, err error)
- func (x *STREAM) XRange(stream string, start string, stop string, count ...int64) (outputSlice []redis.XMessage, notFound bool, err error)
- func (x *STREAM) XRead(readArgs *redis.XReadArgs) (outputSlice []redis.XStream, notFound bool, err error)
- func (x *STREAM) XReadGroup(readGroupArgs *redis.XReadGroupArgs) (outputSlice []redis.XStream, notFound bool, err error)
- func (x *STREAM) XReadStreams(stream ...string) (outputSlice []redis.XStream, notFound bool, err error)
- func (x *STREAM) XRevRange(stream string, start string, stop string, count ...int64) (outputSlice []redis.XMessage, notFound bool, err error)
- func (x *STREAM) XTrim(key string, maxLen int64) error
- func (x *STREAM) XTrimApprox(key string, maxLen int64) error
- type TTL
- func (t *TTL) Expire(key string, bSetMilliseconds bool, expireValue time.Duration) error
- func (t *TTL) ExpireAt(key string, expireTime time.Time) error
- func (t *TTL) Persist(key string) error
- func (t *TTL) TTL(key string, bGetMilliseconds bool) (valTTL int64, notFound bool, err error)
- func (t *TTL) Touch(key ...string) error
- type UTILS
- func (u *UTILS) DBSize() (val int64, err error)
- func (u *UTILS) Keys(match string) (valKeys []string, notFound bool, err error)
- func (u *UTILS) LastSave() (val time.Time, err error)
- func (u *UTILS) ObjectEncoding(key string) (val string, notFound bool, err error)
- func (u *UTILS) ObjectIdleTime(key string) (val time.Duration, notFound bool, err error)
- func (u *UTILS) ObjectRefCount(key string) (val int64, notFound bool, err error)
- func (u *UTILS) Ping() error
- func (u *UTILS) RandomKey() (val string, err error)
- func (u *UTILS) Rename(keyOriginal string, keyNew string) error
- func (u *UTILS) RenameNX(keyOriginal string, keyNew string) error
- func (u *UTILS) Scan(cursor uint64, match string, count int64) (keys []string, resultCursor uint64, err error)
- func (u *UTILS) Sort(key string, sortPattern *redis.Sort) (val []string, notFound bool, err error)
- func (u *UTILS) SortInterfaces(keyToSort string, sortPattern *redis.Sort) (val []interface{}, notFound bool, err error)
- func (u *UTILS) SortStore(keyToSort string, keyToStore string, sortPattern *redis.Sort) error
- func (u *UTILS) Time() (val time.Time, err error)
- func (u *UTILS) Type(key string) (val rediskeytype.RedisKeyType, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BIT ¶
type BIT struct {
// contains filtered or unexported fields
}
BIT defines redis BIT operations
func (*BIT) BitCount ¶
BitCount counts the number of set bits (population counting of bits that are 1) in a string,
offsetFrom = evaluate bitcount begin at offsetFrom position offsetTo = evaluate bitcount until offsetTo position
func (*BIT) BitField ¶
BitField treats redis string as array of bits See detail at https://redis.io/commands/bitfield
Supported Sub Commands:
GET <type> <offset> -- returns the specified bit field SET <type> <offset> <value> -- sets the specified bit field and returns its old value INCRBY <type> <offset> <increment> -- increments or decrements (if negative) the specified bit field and returns the new value
Notes:
i = if integer type, i can be preceeded to indicate signed integer, such as i5 = signed integer 5 u = if integer type, u can be preceeded to indicate unsigned integer, such as u5 = unsigned integer 5 # = if offset is preceeded with #, the specified offset is multiplied by the type width, such as #0 = 0, #1 = 8 when type if 8-bit byte
func (*BIT) BitOp ¶
func (b *BIT) BitOp(keyDest string, bitOpType redisbitop.RedisBitop, keySource ...string) error
BitOpAnd performs bitwise operation between multiple keys (containing string value), stores the result in the destination key, if operation failed, error is returned, if success, nil is returned
Supported:
And, Or, XOr, Not
func (*BIT) BitPos ¶
func (b *BIT) BitPos(key string, bitValue int64, startPosition ...int64) (valPosition int64, err error)
BitPos returns the position of the first bit set to 1 or 0 (as requested via input query) in a string, position of bit is returned from left to right, first byte most significant bit is 0 on left most, second byte most significant bit is at position 8 (after the first byte right most bit 7), and so on
bitValue = 1 or 0 startPosition = bit pos start from this bit offset position
func (*BIT) GetBit ¶
GetBit will return the bit value (1 or 0) at offset position of the value for the key in redis If key is not found or offset is greater than key's value, then blank string is assumed and bit 0 is returned
func (*BIT) SetBit ¶
SetBit will set or clear (1 or 0) the bit at offset in the string value stored by the key in redis, If the key doesn't exist, a new key with the key defined is created, The string holding bit value will grow as needed when offset exceeds the string, grown value defaults with bit 0
bit range = left 0 -> right 8 = byte
type GEO ¶
type GEO struct {
// contains filtered or unexported fields
}
GEO defines redis GEO operations
func (*GEO) GeoAdd ¶
GeoAdd will add geospatial info (lat, lon, name) to the specified key, data is stored into the key as a sorted set, supports later query by radius with GeoRadius or GeoRadiusByMember commands
valid longitude = -180 to 180 degrees valid latitude = -85.05112878 to 85.05112878 degrees
Use ZREM to remove Geo Key (since there is no GEODEL Command)
func (*GEO) GeoDist ¶
func (g *GEO) GeoDist(key string, member1 string, member2 string, unit redisradiusunit.RedisRadiusUnit) (valDist float64, notFound bool, err error)
GeoDist returns the distance between two members in the geospatial index represented by the sorted set
unit = m (meters), km (kilometers), mi (miles), ft (feet)
func (*GEO) GeoHash ¶
func (g *GEO) GeoHash(key string, member ...string) (geoHashSlice []string, notFound bool, err error)
GeoHash returns valid GeoHash string representing the position of one or more elements in a sorted set (added by GeoAdd) This function returns a STANDARD GEOHASH as described on geohash.org site
func (*GEO) GeoPos ¶
GeoPos returns the position (longitude and latitude) of all the specified members of the geospatial index represented by the sorted set at key
func (*GEO) GeoRadius ¶
func (g *GEO) GeoRadius(key string, longitude float64, latitude float64, query *redis.GeoRadiusQuery) (*redis.GeoLocationCmd, error)
GeoRadius returns the members of a sorted set populated with geospatial information using GeoAdd, which are within the borders of the area specified with the center location and the maximum distance from the center (the radius)
radius = units are: m (meters), km (kilometers), mi (miles), ft (feet) withDist = return the distance of returned items from the specified center (using same unit as units specified in the radius) withCoord = return the longitude and latitude coordinates of the matching items
asc = sort returned items from the nearest to the farthest, relative to the center desc = sort returned items from the farthest to the nearest, relative to the center
count = optional limit of return items; default is return all items found, use count to limit the list
store = store the items in a sorted set populated with their geospatial information storeDist = store the items in a sorted set populated with their distance from the center as a floating point number, in the same unit specified in the radius
func (*GEO) GeoRadiusByMember ¶
func (g *GEO) GeoRadiusByMember(key string, member string, query *redis.GeoRadiusQuery) (*redis.GeoLocationCmd, error)
GeoRadiusByMember is same as GeoRadius, except instead of taking as the center of the area to query (long lat), this takes the name of a member already existing inside the geospatial index represented by the sorted set
The position of the specified member is used as the center of the query ¶
radius = units are: m (meters), km (kilometers), mi (miles), ft (feet) withDist = return the distance of returned items from the specified center (using same unit as units specified in the radius) withCoord = return the longitude and latitude coordinates of the matching items
asc = sort returned items from the nearest to the farthest, relative to the center desc = sort returned items from the farthest to the nearest, relative to the center
count = optional limit of return items; default is return all items found, use count to limit the list
store = store the items in a sorted set populated with their geospatial information storeDist = store the items in a sorted set populated with their distance from the center as a floating point number, in the same unit specified in the radius
func (*GEO) GeoRadiusByMemberStore ¶
GeoRadiusByMemberStore is same as GeoRadiusStore, except instead of taking as the center of the area to query (long lat), this takes the name of a member already existing inside the geospatial index represented by the sorted set
The position of the specified member is used as the center of the query ¶
radius = units are: m (meters), km (kilometers), mi (miles), ft (feet) withDist = return the distance of returned items from the specified center (using same unit as units specified in the radius) withCoord = return the longitude and latitude coordinates of the matching items
asc = sort returned items from the nearest to the farthest, relative to the center desc = sort returned items from the farthest to the nearest, relative to the center
count = optional limit of return items; default is return all items found, use count to limit the list
store = store the items in a sorted set populated with their geospatial information storeDist = store the items in a sorted set populated with their distance from the center as a floating point number, in the same unit specified in the radius
func (*GEO) GeoRadiusStore ¶
func (g *GEO) GeoRadiusStore(key string, longitude float64, latitude float64, query *redis.GeoRadiusQuery) error
GeoRadiusStore will store the members of a sorted set populated with geospatial information using GeoAdd, which are within the borders of the area specified with the center location and the maximum distance from the center (the radius)
radius = units are: m (meters), km (kilometers), mi (miles), ft (feet) withDist = return the distance of returned items from the specified center (using same unit as units specified in the radius) withCoord = return the longitude and latitude coordinates of the matching items
asc = sort returned items from the nearest to the farthest, relative to the center desc = sort returned items from the farthest to the nearest, relative to the center
count = optional limit of return items; default is return all items found, use count to limit the list
store = store the items in a sorted set populated with their geospatial information storeDist = store the items in a sorted set populated with their distance from the center as a floating point number, in the same unit specified in the radius
type HASH ¶
type HASH struct {
// contains filtered or unexported fields
}
HASH defines redis HASH operations
func (*HASH) HDel ¶
HDel removes the specified 'fields' from the hash stored at key, any specified 'fields' that do not exist in the hash are ignored, if key does not exist, it is treated as an empty hash, and 0 is returned
func (*HASH) HExists ¶
HExists returns if field is an existing field in the hash stored at key
1 = exists; 0 = not exist or key not exist
func (*HASH) HGet ¶
func (h *HASH) HGet(key string, field string, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
HGet returns the value associated with 'field' in the hash stored at key
func (*HASH) HGetAll ¶
HGetAll returns all fields and values of the hash store at key, in the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash
func (*HASH) HIncrBy ¶
HIncrBy increments or decrements the number (int64) value at 'field' in the hash stored at key, if key does not exist, a new key holding a hash is created, if 'field' does not exist then the value is set to 0 before operation is performed
this function supports both increment and decrement (although name of function is increment)
func (*HASH) HIncrByFloat ¶
HIncrByFloat increments or decrements the number (float64) value at 'field' in the hash stored at key, if key does not exist, a new key holding a hash is created, if 'field' does not exist then the value is set to 0 before operation is performed
this function supports both increment and decrement (although name of function is increment)
func (*HASH) HKeys ¶
HKeys returns all field names in the hash stored at key, field names are the element keys
func (*HASH) HMGet ¶
func (h *HASH) HMGet(key string, field ...string) (outputSlice []interface{}, notFound bool, err error)
HMGet will return the values associated with the specified 'fields' in the hash stored at key, For every 'field' that does not exist in the hash, a nil value is returned, If key is not existent, then nil is returned for all values
func (*HASH) HMSet ¶
HMSet will set the specified 'fields' to their respective values in the hash stored by key, This command overrides any specified 'fields' already existing in the hash, If key does not exist, a new key holding a hash is created
func (*HASH) HScan ¶
func (h *HASH) HScan(key string, cursor uint64, match string, count int64) (outputKeys []string, outputCursor uint64, err error)
HScan is used to incrementally iterate over a set of fields for hash stored at key, HScan is a cursor based iterator, at every call of the command, redis returns an updated cursor that client must use for next call to sort,
start iteration = cursor set to 0 stop iteration = when redis returns cursor value of 0
match = filters elements based on match filter, for elements retrieved from redis before return to client
glob-style patterns: 1) h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match) 2) h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match) 3) h*llo = * represents any single or more char match (hllo, heeeelo match) 4) h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match) 5) h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match) 6) h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match) 7) Use \ to escape special characters if needing to match verbatim
count = hint to redis count of elements to retrieve in the call
func (*HASH) HSet ¶
HSet will set 'field' in hash stored at key to 'value', if key does not exist, a new key holding a hash is created,
if 'field' already exists in the hash, it will be overridden if 'field' does not exist, it will be added
type LIST ¶
type LIST struct {
// contains filtered or unexported fields
}
LIST defines redis LIST operations
func (*LIST) LIndex ¶
func (l *LIST) LIndex(key string, index int64, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
LIndex returns the element by list index position, for the value stored in list by key, Index is zero-based, Negative Index can be used to denote reverse order,
such as -1 = last element such as -2 = second to last element, and so on
Error is returned if value at key is not a list
func (*LIST) LLen ¶
LLen returns the length of the list stored at key, if key does not exist, it is treated as empty list and 0 is returned,
Error is returned if value at key is not a list
func (*LIST) LPop ¶
func (l *LIST) LPop(key string, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
LPop will remove and return the first element from the list stored at key
func (*LIST) LPush ¶
LPush stores all the specified values at the head of the list as defined by the key, if key does not exist, then empty list is created before performing the push operation (unless keyMustExist bit is set)
Elements are inserted one after the other to the head of the list, from the leftmost to the rightmost, for example, LPush mylist a b c will result in a list containing c as first element, b as second element, and a as third element
error is returned if the key is not holding a value of type list
func (*LIST) LRange ¶
func (l *LIST) LRange(key string, start int64, stop int64) (outputSlice []string, notFound bool, err error)
LRange returns the specified elements of the list stored at key, Offsets start and stop are zero based indexes, Offsets can be negative, where -1 is the last element, while -2 is next to last element, and so on,
Offsets start > stop, empty list is returned, Offsets stop > last element, stop uses last element instead
Example:
start top = 0 - 10 = returns 11 elements (0 to 10 = 11)
func (*LIST) LRem ¶
LRem removes the first count occurrences of elements equal to 'element value' from list stored at key count indicates number of occurrences
count > 0 = removes elements equal to 'element value' moving from head to tail count < 0 = removes elements equal to 'element value' moving from tail to head count = 0 = removes all elements equal to 'element value'
Example:
LREM list 02 "hello" = removes the last two occurrences of "hello" in the list stored at key named 'list'
func (*LIST) LTrim ¶
LTrim will trim an existing list so that it will contian only the specified range of elements specified, Both start and stop are zero-based indexes, Both start and stop can be negative, where -1 is the last element, while -2 is the second to last element
Example:
LTRIM foobar 0 2 = modifies the list store at key named 'foobar' so that only the first 3 elements of the list will remain
func (*LIST) RPop ¶
func (l *LIST) RPop(key string, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
RPop removes and returns the last element of the list stored at key
func (*LIST) RPopLPush ¶
func (l *LIST) RPopLPush(keySource string, keyDest string, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
RPopLPush will atomically remove and return last element of the list stored at keySource, and then push the returned element at first element position (head) of the list stored at keyDest
func (*LIST) RPush ¶
RPush stores all the specified values at the tail of the list as defined by the key, if key does not exist, then empty list is created before performing the push operation (unless keyMustExist bit is set)
Elements are inserted one after the other to the tail of the list, from the leftmost to the rightmost, for example, RPush mylist a b c will result in a list containing a as first element, b as second element, and c as third element
error is returned if the key is not holding a value of type list
type PIPELINE ¶
type PIPELINE struct {
// contains filtered or unexported fields
}
PIPELINE defines batched pipeline patterns
func (*PIPELINE) Pipeline ¶
Pipeline allows actions against redis to be handled in a batched fashion
func (*PIPELINE) Pipelined ¶
Pipelined allows actions against redis to be handled in a batched fashion
func (*PIPELINE) TxPipeline ¶
TxPipeline allows actions against redis to be handled in a batched fashion
func (*PIPELINE) TxPipelined ¶
TxPipelined allows actions against redis to be handled in a batched fashion
type PUBSUB ¶
type PUBSUB struct {
// contains filtered or unexported fields
}
PUBSUB defines redis PUB SUB operations
func (*PUBSUB) PSubscribe ¶
PSubscribe (Pattern Subscribe) will subscribe client to the given pattern channels (glob-style), a pointer to redis PubSub object is returned upon successful subscribe
Once client is subscribed, do not call other redis actions, other than Subscribe, PSubscribe, Ping, Unsubscribe, PUnsubscribe, and Quit (Per Redis Doc)
glob-style patterns:
- h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match)
- h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match)
- h*llo = * represents any single or more char match (hllo, heeeelo match)
- h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match)
- h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match)
- h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match)
- Use \ to escape special characters if needing to match verbatim
func (*PUBSUB) PubSubChannels ¶
PubSubChannels lists currently active channels, active channel = pub/sub channel with one or more subscribers (excluding clients subscribed to patterns), pattern = optional, channels matching specific glob-style pattern are listed; otherwise, all channels listed
glob-style patterns:
- h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match)
- h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match)
- h*llo = * represents any single or more char match (hllo, heeeelo match)
- h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match)
- h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match)
- h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match)
- Use \ to escape special characters if needing to match verbatim
func (*PUBSUB) PubSubNumPat ¶
PubSubNumPat (Pub/Sub Number of Patterns) returns the number of subscriptions to patterns (that were using PSubscribe Command), This counts both clients subscribed to patterns, and also total number of patterns all the clients are subscribed to
func (*PUBSUB) PubSubNumSub ¶
PubSubNumSub (Pub/Sub Number of Subscribers) returns number of subscribers (not counting clients subscribed to patterns) for the specific channels
func (*PUBSUB) Publish ¶
Publish will post a message to a given channel, returns number of clients that received the message
func (*PUBSUB) Subscribe ¶
Subscribe (Non-Pattern Subscribe) will subscribe client to the given channels, a pointer to redis PubSub object is returned upon successful subscribe
Once client is subscribed, do not call other redis actions, other than Subscribe, PSubscribe, Ping, Unsubscribe, PUnsubscribe, and Quit (Per Redis Doc)
type Redis ¶
type Redis struct { // config fields AwsRedisWriterEndpoint string AwsRedisReaderEndpoint string // objects containing wrapped functions BIT *BIT LIST *LIST HASH *HASH SET *SET SORTED_SET *SORTED_SET GEO *GEO STREAM *STREAM PUBSUB *PUBSUB PIPELINE *PIPELINE TTL *TTL UTILS *UTILS // contains filtered or unexported fields }
Redis defines wrapper struct to handle redis interactions with AWS ElasticCache Redis service (using go-redis package)
IMPORTANT
AWS ELASTICACHE REDIS lives within the VPC that the cluster is launched Access is allowed ONLY WITHIN EC2 in the same VPC There is no external public access since AWS Redis uses private IP only
Dev Testing
Test On AWS EC2 (via SSH into EC2) since elastic cache redis is deployed within vpc access only
Reference Info
- Redis Commands Documentation = https://redis.io/commands
- Go-Redis Documentation = https://pkg.go.dev/github.com/go-redis/redis?tab=doc
func (*Redis) Append ¶
Append will append a value to the existing value under the given key in redis, if key does not exist, a new key based on the given key is created
func (*Redis) Connect ¶
Connect will establish aws redis writer and reader endpoint client connections
func (*Redis) Disconnect ¶
func (r *Redis) Disconnect()
Disconnect will close aws redis writer and reader endpoints
func (*Redis) Exists ¶
Exists checks if one or more keys exists in redis
foundCount = 0 indicates not found; > 0 indicates found count
func (*Redis) Float64AddOrReduce ¶
func (r *Redis) Float64AddOrReduce(key string, val float64) (newVal float64, notFound bool, err error)
Float64AddOrReduce will add or reduce float64 value against a key in redis, and return the new value if found and performed
func (*Redis) GetFloat64 ¶
GetFloat64 gets float64 value from redis by key
func (*Redis) GetJson ¶
GetJson gets Json object from redis by key (Json is stored as string in redis, unmarshaled to target object via get)
func (*Redis) GetRange ¶
GetRange gets val between start and end positions from string value stored by key in redis
func (*Redis) GetSet ¶
GetSet will get old string value from redis by key, and then set new string value into redis by the same key
func (*Redis) Int64AddOrReduce ¶
func (r *Redis) Int64AddOrReduce(key string, val int64, isReduce ...bool) (newVal int64, notFound bool, err error)
Int64AddOrReduce will add or reduce int64 value against a key in redis, and return the new value if found and performed
func (*Redis) MSet ¶
MSet is helper to set multiple values into redis by keys, optional parameter setIfNotExists indicates if instead MSetNX is to be used
notes
kvMap = map of key string, and interface{} value
func (*Redis) PFAdd ¶
PFAdd is a HyperLogLog function to uniquely accumulate the count of a specific value to redis, such as email hit count, user hit count, ip address hit count etc, that is based on the unique occurences of such value
func (*Redis) PFCount ¶
PFCount is a HyperLogLog function to retrieve the current count associated with the given unique value in redis, Specify one or more keys, if multiple keys used, the result count is the union of all keys' unique value counts
func (*Redis) PFMerge ¶
PFMerge is a HyperLogLog function to merge two or more HyperLogLog as defined by keys together
func (*Redis) SetBase ¶
func (r *Redis) SetBase(key string, val interface{}, setCondition redissetcondition.RedisSetCondition, expires ...time.Duration) error
Set is helper to set value into redis by key
notes
setCondition = support for SetNX and SetXX
func (*Redis) SetFloat64 ¶
SetFloat64 sets float64 value into redis by key
func (*Redis) SetJson ¶
SetJson sets Json object into redis by key (Json object is marshaled into string and then saved to redis)
func (*Redis) SetRange ¶
SetRange sets val into key's stored value in redis, offset by the offset number
example:
- "Hello World"
- Offset 6 = W
- Val "Xyz" replaces string from Offset Position 6
- End Result String = "Hello Xyzld"
type SET ¶
type SET struct {
// contains filtered or unexported fields
}
SET defines redis SET operations
func (*SET) SAdd ¶
SAdd adds the specified members to the set stored at key, Specified members that are already a member of this set are ignored, If key does not exist, a new set is created before adding the specified members
Error is returned when the value stored at key is not a set
func (*SET) SDiff ¶
SDiff returns the members of the set resulting from the difference between the first set and all the successive sets
Example:
key1 = { a, b, c, d } key2 = { c } key3 = { a, c, e } SDIFF key1, key2, key3 = { b, d } { b, d } is returned because this is the difference delta
func (*SET) SDiffStore ¶
SDiffStore will store the set differential to destination, if destination already exists, it is overwritten
Example:
key1 = { a, b, c, d } key2 = { c } key3 = { a, c, e } SDIFF key1, key2, key3 = { b, d } { b, d } is stored because this is the difference delta
func (*SET) SInter ¶
SInter returns the members of the set resulting from the intersection of all the given sets
Example:
Key1 = { a, b, c, d } Key2 = { c } Key3 = { a, c, e } SINTER key1 key2 key3 = { c } { c } is returned because this is the intersection on all keys (appearing in all keys)
func (*SET) SInterStore ¶
SInterStore stores the members of the set resulting from the intersection of all the given sets to destination, if destination already exists, it is overwritten
Example:
Key1 = { a, b, c, d } Key2 = { c } Key3 = { a, c, e } SINTER key1 key2 key3 = { c } { c } is stored because this is the intersection on all keys (appearing in all keys)
func (*SET) SMembersMap ¶
SMembersMap returns all the members of the set value stored at key, via map
func (*SET) SMove ¶
SMove will move a member from the set at 'source' to the set at 'destination' atomically, The element will appear to be a member of source or destination for other clients
If source set does not exist, or does not contain the specified element, no operation is performed and 0 is returned, Otherwise, the element is removed from the source set and added to the destination set
If the specified element already exist in the destination set, it is only removed from the source set ¶
Error is returned if the source or destination does not hold a set value
func (*SET) SPop ¶
func (s *SET) SPop(key string, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
SPop removes and returns one random element from the set value stored at key
func (*SET) SPopN ¶
SPop removes and returns one or more random element from the set value stored at key
count > 0 = returns an array of count distinct elements (non-repeating), up to the set elements size count < 0 = returns an array of count elements (may be repeating), and up to the count size (selected members may still be part of the subsequent selection process)
func (*SET) SRandMember ¶
func (s *SET) SRandMember(key string, outputDataType redisdatatype.RedisDataType, outputObjectPtr interface{}) (notFound bool, err error)
SRandMember returns a random element from the set value stored at key
func (*SET) SRandMemberN ¶
func (s *SET) SRandMemberN(key string, count int64) (outputSlice []string, notFound bool, err error)
SRandMemberN returns one or more random elements from the set value stored at key, with count indicating return limit
count > 0 = returns an array of count distinct elements (non-repeating), up to the set elements size count < 0 = returns an array of count elements (may be repeating), and up to the count size (selected members may still be part of the subsequent selection process)
func (*SET) SRem ¶
SRem removes the specified members from the set stored at key, Specified members that are not a member of this set are ignored, If key does not exist, it is treated as an empty set and this command returns 0
Error is returned if the value stored at key is not a set
func (*SET) SScan ¶
func (s *SET) SScan(key string, cursor uint64, match string, count int64) (outputKeys []string, outputCursor uint64, err error)
SScan is used to incrementally iterate over a set of fields for set stored at key, SScan is a cursor based iterator, at every call of the command, redis returns an updated cursor that client must use for next call to sort,
start iteration = cursor set to 0 stop iteration = when redis returns cursor value of 0
match = filters elements based on match filter, for elements retrieved from redis before return to client
glob-style patterns: 1) h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match) 2) h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match) 3) h*llo = * represents any single or more char match (hllo, heeeelo match) 4) h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match) 5) h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match) 6) h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match) 7) Use \ to escape special characters if needing to match verbatim
count = hint to redis count of elements to retrieve in the call
func (*SET) SUnion ¶
SUnion returns the members of the set resulting from the union of all the given sets, if a key is not existent, it is treated as a empty set
Example:
key1 = { a, b, c } key2 = { c } key3 = { a, c, e } SUNION key1 key2 key3 = { a, b, c, d, e }
func (*SET) SUnionStore ¶
SUnionStore will store the members of the set resulting from the union of all the given sets to 'destination' if a key is not existent, it is treated as a empty set, if 'destination' already exists, it is overwritten
Example:
key1 = { a, b, c } key2 = { c } key3 = { a, c, e } SUNION key1 key2 key3 = { a, b, c, d, e }
type SORTED_SET ¶
type SORTED_SET struct {
// contains filtered or unexported fields
}
SORTED_SET defines SORTED SET operations
func (*SORTED_SET) ZAdd ¶
func (z *SORTED_SET) ZAdd(key string, setCondition redissetcondition.RedisSetCondition, getChanged bool, member ...*redis.Z) error
ZAdd will add all the specified members with the specified scores to the sorted set stored at key, If a specified member is already a member of the sorted set, the score is updated and the element reinserted at the right position to ensure the correct ordering
If key does not exist, a new sorted set with the specified members is created as if the set was empty ¶
If value at key is not a sorted set, then error is returned ¶
Score Values:
- Should be string representation of a double precision floating point number
Other ZAdd Options:
- ZAdd XX / XXCH = only update elements that already exists, never add elements
- ZAdd NX / NXCH = don't update already existing elements, always add new elements
- ZAdd CH = modify the return value from the number of new or updated elements added, CH = Changed
func (*SORTED_SET) ZCard ¶
func (z *SORTED_SET) ZCard(key string) (val int64, notFound bool, err error)
ZCard returns the sorted set cardinality (number of elements) of the sorted set stored at key
func (*SORTED_SET) ZCount ¶
func (z *SORTED_SET) ZCount(key string, min string, max string) (val int64, notFound bool, err error)
ZCount returns the number of elements in the sorted set at key with a score between min and max
func (*SORTED_SET) ZIncr ¶
func (z *SORTED_SET) ZIncr(key string, setCondition redissetcondition.RedisSetCondition, member *redis.Z) error
ZIncr will increment the score of member in sorted set at key
Also support for ZIncrXX (member must exist), ZIncrNX (member must not exist)
func (*SORTED_SET) ZIncrBy ¶
func (z *SORTED_SET) ZIncrBy(key string, increment float64, member string) error
ZIncrBy increments or decrements the score of member in the sorted set stored at key, with custom increment value, If member does not exist in the sorted set, it is added with increment value as its score, If key does not exist, a new sorted set with the specified member as its sole member is created
Error is returned if the value stored at key is not a sorted set ¶
Score should be string representation of a numeric value, and accepts double precision floating point numbers To decrement, use negative value
func (*SORTED_SET) ZInterStore ¶
func (z *SORTED_SET) ZInterStore(keyDest string, store *redis.ZStore) error
ZInterStore computes the intersection of numKeys sorted set given by the specified keys, and stores the result in 'destination'
numKeys (input keys) are required
If 'destination' already exists, it is overwritten
Default Logic:
Resulting score of an element is the sum of its scores in the sorted set where it exists
func (*SORTED_SET) ZLexCount ¶
func (z *SORTED_SET) ZLexCount(key string, min string, max string) (val int64, notFound bool, err error)
ZLexCount returns the number of elements in the sorted set at key, with a value between min and max
func (*SORTED_SET) ZPopMax ¶
func (z *SORTED_SET) ZPopMax(key string, count ...int64) (outputSlice []redis.Z, notFound bool, err error)
ZPopMax removes and returns up to the count of members with the highest scores in the sorted set stored at key, Specifying more count than members will not cause error, rather given back smaller result set, Returning elements ordered with highest score first, then subsequent and so on
func (*SORTED_SET) ZPopMin ¶
func (z *SORTED_SET) ZPopMin(key string, count ...int64) (outputSlice []redis.Z, notFound bool, err error)
ZPopMin removes and returns up to the count of members with the lowest scores in the sorted set stored at key, Specifying more count than members will not cause error, rather given back smaller result set, Returning elements ordered with lowest score first, then subsequently higher score, and so on
func (*SORTED_SET) ZRange ¶
func (z *SORTED_SET) ZRange(key string, start int64, stop int64) (outputSlice []string, notFound bool, err error)
ZRange returns the specified range of elements in the sorted set stored at key, The elements are considered to be ordered form lowest to the highest score, Lexicographical order is used for elements with equal score
start and stop are both zero-based indexes, start and stop may be negative, where -1 is the last index, and -2 is the second to the last index, start and stop are inclusive range
func (*SORTED_SET) ZRangeByLex ¶
func (z *SORTED_SET) ZRangeByLex(key string, opt *redis.ZRangeBy) (outputSlice []string, notFound bool, err error)
ZRangeByLex returns all the elements in the sorted set at key with a value between min and max
func (*SORTED_SET) ZRangeByScore ¶
func (z *SORTED_SET) ZRangeByScore(key string, opt *redis.ZRangeBy) (outputSlice []string, notFound bool, err error)
ZRangeByScore returns all the elements in the sorted set at key with a score between min and max, Elements are considered to be ordered from low to high scores
func (*SORTED_SET) ZRangeByScoreWithScores ¶
func (z *SORTED_SET) ZRangeByScoreWithScores(key string, opt *redis.ZRangeBy) (outputSlice []redis.Z, notFound bool, err error)
ZRangeByScoreWithScores returns all the elements in the sorted set at key with a score between min and max, Elements are considered to be ordered from low to high scores
func (*SORTED_SET) ZRank ¶
ZRank returns the rank of member in the sorted set stored at key, with the scores ordered from low to high, The rank (or index) is zero-based, where lowest member is index 0 (or rank 0)
func (*SORTED_SET) ZRem ¶
func (z *SORTED_SET) ZRem(key string, member ...interface{}) error
ZRem removes the specified members from the stored set stored at key, Non-existing members are ignored
Error is returned if the value at key is not a sorted set
func (*SORTED_SET) ZRemRangeByLex ¶
func (z *SORTED_SET) ZRemRangeByLex(key string, min string, max string) error
ZRemRangeByLex removes all elements in the sorted set stored at key, between the lexicographical range specified by min and max
func (*SORTED_SET) ZRemRangeByRank ¶
func (z *SORTED_SET) ZRemRangeByRank(key string, start int64, stop int64) error
ZRemRangeByRank removes all elements in the sorted set stored at key, with rank between start and stop
Both start and stop are zero-based, Both start and stop can be negative, where -1 is the element with highest score, -2 is the element with next to highest score, and so on
func (*SORTED_SET) ZRemRangeByScore ¶
func (z *SORTED_SET) ZRemRangeByScore(key string, min string, max string) error
ZRemRangeByScore removes all elements in the sorted set stored at key, with a score between min and max (inclusive)
func (*SORTED_SET) ZRevRange ¶
func (z *SORTED_SET) ZRevRange(key string, start int64, stop int64) (outputSlice []string, notFound bool, err error)
ZRevRange returns the specified range of elements in the sorted set stored at key, With elements ordered from highest to the lowest score, Descending lexicographical order is used for elements with equal score
func (*SORTED_SET) ZRevRangeByScoreWithScores ¶
func (z *SORTED_SET) ZRevRangeByScoreWithScores(key string, opt *redis.ZRangeBy) (outputSlice []redis.Z, notFound bool, err error)
ZRevRangeByScoreWithScores returns all the elements (with scores) in the sorted set at key, with a score between max and min (inclusive), With elements ordered from highest to lowest scores, Descending lexicographical order is used for elements with equal score
func (*SORTED_SET) ZRevRangeWithScores ¶
func (z *SORTED_SET) ZRevRangeWithScores(key string, start int64, stop int64) (outputSlice []redis.Z, notFound bool, err error)
ZRevRangeWithScores returns the specified range of elements (with scores) in the sorted set stored at key, With elements ordered from highest to the lowest score, Descending lexicographical order is used for elements with equal score
func (*SORTED_SET) ZRevRank ¶
ZRevRank returns the rank of member in the sorted set stored at key, with the scores ordered from high to low, Rank (index) is ordered from high to low, and is zero-based, where 0 is the highest rank (index) ZRevRank is opposite of ZRank
func (*SORTED_SET) ZScan ¶
func (z *SORTED_SET) ZScan(key string, cursor uint64, match string, count int64) (outputKeys []string, outputCursor uint64, err error)
ZScan is used to incrementally iterate over a sorted set of fields stored at key, ZScan is a cursor based iterator, at every call of the command, redis returns an updated cursor that client must use for next call to sort,
start iteration = cursor set to 0 stop iteration = when redis returns cursor value of 0
match = filters elements based on match filter, for elements retrieved from redis before return to client
glob-style patterns: 1) h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match) 2) h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match) 3) h*llo = * represents any single or more char match (hllo, heeeelo match) 4) h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match) 5) h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match) 6) h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match) 7) Use \ to escape special characters if needing to match verbatim
count = hint to redis count of elements to retrieve in the call
func (*SORTED_SET) ZScore ¶
ZScore returns the score of member in the sorted set at key, if member is not existent in the sorted set, or key does not exist, nil is returned
func (*SORTED_SET) ZUnionStore ¶
func (z *SORTED_SET) ZUnionStore(keyDest string, store *redis.ZStore) error
ZUnionStore computes the union of numKeys sorted set given by the specified keys, and stores the result in 'destination'
numKeys (input keys) are required
type STREAM ¶
type STREAM struct {
// contains filtered or unexported fields
}
STREAM defines redis STREAM operations
func (*STREAM) XAck ¶
XAck removes one or multiple messages from the 'pending entries list (PEL)' of a stream consumer group
A message is pending, and as such stored inside the PEL, when it was delivered to some consumer ¶
Once a consumer successfully processes a message, it should call XAck to remove the message so it does not get processed again (and releases message from memory in redis)
func (*STREAM) XAdd ¶
XAdd appends the specified stream entry to the stream at the specified key, If the key does not exist, as a side effect of running this command the key is created with a stream value
func (*STREAM) XClaim ¶
func (x *STREAM) XClaim(claimArgs *redis.XClaimArgs) (valMessages []redis.XMessage, notFound bool, err error)
XClaim in the context of stream consumer group, this function changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument
func (*STREAM) XClaimJustID ¶
func (x *STREAM) XClaimJustID(claimArgs *redis.XClaimArgs) (outputSlice []string, notFound bool, err error)
XClaimJustID in the context of stream consumer group, this function changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument
func (*STREAM) XGroupCreate ¶
XGroupCreate will create a new consumer group associated with a stream
func (*STREAM) XGroupCreateMkStream ¶
XGroupCreateMkStream will create a new consumer group, and create a stream if stream doesn't exist
func (*STREAM) XGroupDelConsumer ¶
XGroupDelConsumer removes a given consumer from a consumer group
func (*STREAM) XGroupDestroy ¶
XGroupDestroy will destroy a consumer group even if there are active consumers and pending messages
func (*STREAM) XGroupSetID ¶
XGroupSetID will set the next message to deliver, Normally the next ID is set when the consumer is created, as the last argument to XGroupCreate, However, using XGroupSetID resets the next message ID in case prior message needs to be reprocessed
func (*STREAM) XInfoGroups ¶
func (x *STREAM) XInfoGroups(key string) (outputSlice []redis.XInfoGroups, notFound bool, err error)
XInfoGroups retrieves different information about the streams, and associated consumer groups
func (*STREAM) XPending ¶
func (x *STREAM) XPending(stream string, group string) (val *redis.XPending, notFound bool, err error)
XPending fetches data from a stream via a consumer group, and not acknowledging such data, its like creating pending entries
func (*STREAM) XPendingExt ¶
func (x *STREAM) XPendingExt(pendingArgs *redis.XPendingExtArgs) (outputSlice []redis.XPendingExt, notFound bool, err error)
XPendingExt fetches data from a stream via a consumer group, and not acknowledging such data, its like creating pending entries
func (*STREAM) XRange ¶
func (x *STREAM) XRange(stream string, start string, stop string, count ...int64) (outputSlice []redis.XMessage, notFound bool, err error)
XRange returns the stream entries matching a given range of IDs, Range is specified by a minimum and maximum ID, Ordering is lowest to highest
func (*STREAM) XRead ¶
func (x *STREAM) XRead(readArgs *redis.XReadArgs) (outputSlice []redis.XStream, notFound bool, err error)
XRead will read data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller
func (*STREAM) XReadGroup ¶
func (x *STREAM) XReadGroup(readGroupArgs *redis.XReadGroupArgs) (outputSlice []redis.XStream, notFound bool, err error)
XReadGroup is a special version of XRead command with support for consumer groups
func (*STREAM) XReadStreams ¶
func (x *STREAM) XReadStreams(stream ...string) (outputSlice []redis.XStream, notFound bool, err error)
XReadStreams is a special version of XRead command for streams
func (*STREAM) XRevRange ¶
func (x *STREAM) XRevRange(stream string, start string, stop string, count ...int64) (outputSlice []redis.XMessage, notFound bool, err error)
XRevRange returns the stream entries matching a given range of IDs, Range is specified by a maximum and minimum ID, Ordering is highest to lowest
type TTL ¶
type TTL struct {
// contains filtered or unexported fields
}
TTL defines TTL and Persist related redis patterns
func (*TTL) Expire ¶
Expire sets a timeout on key (seconds or milliseconds based on input parameter)
expireValue = in seconds or milliseconds
func (*TTL) ExpireAt ¶
ExpireAt sets the hard expiration date time based on unix timestamp for a given key
Setting expireTime to the past immediately deletes the key
type UTILS ¶
type UTILS struct {
// contains filtered or unexported fields
}
UTILS defines redis helper functions
func (*UTILS) Keys ¶
Keys returns all keys matching given pattern (use with extreme care, use for debugging only, may slow production system down significantly)
start iteration = cursor set to 0 stop iteration = when redis returns cursor value of 0
match = filters elements based on match filter, for elements retrieved from redis before return to client
glob-style patterns: 1) h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match) 2) h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match) 3) h*llo = * represents any single or more char match (hllo, heeeelo match) 4) h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match) 5) h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match) 6) h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match) 7) Use \ to escape special characters if needing to match verbatim
func (*UTILS) ObjectEncoding ¶
ObjectEncoding returns the internal representation used in order to store the value associated with a key
func (*UTILS) ObjectIdleTime ¶
ObjectIdleTime returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations)
func (*UTILS) ObjectRefCount ¶
ObjectRefCount returns the number of references of the value associated with the specified key
func (*UTILS) Ping ¶
Ping will ping the redis server to see if its up
result nil = success; otherwise error info is returned via error object
func (*UTILS) Rename ¶
Rename will rename the keyOriginal to be keyNew in redis, if keyNew already exist in redis, then Rename will override existing keyNew with keyOriginal if keyOriginal is not in redis, error is returned
func (*UTILS) RenameNX ¶
RenameNX will rename the keyOriginal to be keyNew IF keyNew does not yet exist in redis if RenameNX fails due to keyNew already exist, or other errors, the error is returned
func (*UTILS) Scan ¶
func (u *UTILS) Scan(cursor uint64, match string, count int64) (keys []string, resultCursor uint64, err error)
Scan is used to incrementally iterate over a set of keys, Scan is a cursor based iterator, at every call of the command, redis returns an updated cursor that client must use for next call to sort,
start iteration = cursor set to 0 stop iteration = when redis returns cursor value of 0
match = filters elements based on match filter, for elements retrieved from redis before return to client
glob-style patterns: 1) h?llo = ? represents any single char match (hello, hallo, hxllo match, but heello not match) 2) h??llo = ?? represents any two char match (heello, haello, hxyllo match, but heeello not match) 3) h*llo = * represents any single or more char match (hllo, heeeelo match) 4) h[ae]llo = [ae] represents char inside [ ] that are to match (hello, hallo match, but hillo not match) 5) h[^e]llo = [^e] represents any char other than e to match (hallo, hbllo match, but hello not match) 6) h[a-b]llo = [a-b] represents any char match between the a-b range (hallo, hbllo match, but hcllo not match) 7) Use \ to escape special characters if needing to match verbatim
count = hint to redis count of elements to retrieve in the call
func (*UTILS) Sort ¶
Sort will sort values as defined by keyToSort, along with sortPattern, and then return the sorted data via string slice sort is applicable to list, set, or sorted set as defined by key
sortPattern = defines the sort conditions (see redis sort documentation for details)
func (*UTILS) SortInterfaces ¶
func (u *UTILS) SortInterfaces(keyToSort string, sortPattern *redis.Sort) (val []interface{}, notFound bool, err error)
SortInterfaces will sort values as defined by keyToSort, along with sortPattern, and then return the sorted data via []interface{} sort is applicable to list, set, or sorted set as defined by key
sortPattern = defines the sort conditions (see redis sort documentation for details)
func (*UTILS) SortStore ¶
SortStore will sort values defined by keyToSort, and sort according to sortPattern, and set sorted results into keyToStore in redis sort is applicable to list, set, or sorted set as defined by key
sortPattern = defines the sort conditions (see redis sort documentation for details)
func (*UTILS) Type ¶
func (u *UTILS) Type(key string) (val rediskeytype.RedisKeyType, err error)
Type returns the redis key's value type stored expected result in string = list, set, zset, hash, and stream