Documentation ¶
Index ¶
- Variables
- type BytesValue
- type Client
- func (c Client) DECR(key string) (after int64, err error)
- func (c Client) DECRBY(key string, delta int64) (after int64, err error)
- func (c Client) GEOADD(key string, members map[string]GLocation) (newlyAddedMembers map[string]GLocation, err error)
- func (c Client) GEODIST(key string, member1, member2 string, unit GUnit) (distance float64, ok bool, err error)
- func (c Client) GEOHASH(key string, members ...string) (geohashes map[string]string, err error)
- func (c Client) GEOPOS(key string, members ...string) (locations map[string]GLocation, err error)
- func (c Client) GEORADIUS(key string, center GLocation, radius float64, radiusUnit GUnit, count int64) (positions map[string]GLocation, err error)
- func (c Client) GEORADIUSBYMEMBER(key string, member string, radius float64, radiusUnit GUnit, count int64) (positions map[string]GLocation, err error)
- func (c Client) GET(key string) (val ReturnValue, err error)
- func (c Client) GETSET(key string, value Value) (oldValue ReturnValue, err error)
- func (c Client) HDEL(key string, fields ...string) (deletedFields []string, err error)
- func (c Client) HEXISTS(key string, field string) (exists bool, err error)
- func (c Client) HGET(key string, field string) (val ReturnValue, err error)
- func (c Client) HGETALL(key string) (fieldValues map[string]ReturnValue, err error)
- func (c Client) HINCRBY(key string, field string, delta int64) (after int64, err error)
- func (c Client) HINCRBYFLOAT(key string, field string, delta float64) (after float64, err error)
- func (c Client) HKEYS(key string) (keys []string, err error)
- func (c Client) HLEN(key string) (count int64, err error)
- func (c Client) HMGET(key string, fields ...string) (values map[string]ReturnValue, err error)
- func (c Client) HMSET(key string, fieldValues map[string]Value) (err error)
- func (c Client) HSET(key string, fieldValues map[string]Value) (newlySavedFields map[string]Value, err error)
- func (c Client) HSETNX(key string, field string, value Value) (ok bool, err error)
- func (c Client) HVALS(key string) (values []ReturnValue, err error)
- func (c Client) INCR(key string) (after int64, err error)
- func (c Client) INCRBY(key string, delta int64) (after int64, err error)
- func (c Client) INCRBYFLOAT(key string, delta float64) (after float64, err error)
- func (c Client) LINDEX(key string, index int64) (element ReturnValue, err error)
- func (c Client) LINSERT(key string, side LSide, pivot, element Value) (newLength int64, done bool, err error)
- func (c Client) LLEN(key string) (length int64, err error)
- func (c Client) LPOP(key string) (element ReturnValue, err error)
- func (c Client) LPUSH(key string, elements ...Value) (newLength int64, err error)
- func (c Client) LPUSHX(key string, elements ...Value) (newLength int64, err error)
- func (c Client) LRANGE(key string, start, stop int64) (elements []ReturnValue, err error)
- func (c Client) LREM(key string, side LSide, element Value) (newLength int64, done bool, err error)
- func (c Client) LSET(key string, index int64, element string) (ok bool, err error)
- func (c Client) MGET(keys ...string) (values map[string]ReturnValue, err error)
- func (c Client) MSET(data map[string]Value) (err error)
- func (c Client) MSETNX(data map[string]Value) (ok bool, err error)
- func (c Client) RPOP(key string) (element ReturnValue, err error)
- func (c Client) RPOPLPUSH(sourceKey string, destinationKey string) (element ReturnValue, err error)
- func (c Client) RPUSH(key string, elements ...Value) (newLength int64, err error)
- func (c Client) RPUSHX(key string, elements ...Value) (newLength int64, err error)
- func (c Client) SADD(key string, members ...string) (addedMembers []string, err error)
- func (c Client) SCARD(key string) (count int64, err error)
- func (c Client) SDIFF(key string, subtractKeys ...string) (members []string, err error)
- func (c Client) SDIFFSTORE(destinationKey string, sourceKey string, subtractKeys ...string) (count int64, err error)
- func (c Client) SET(key string, value Value, flag Flag) (ok bool, err error)
- func (c Client) SETNX(key string, value Value) (ok bool, err error)
- func (c Client) SINTER(key string, otherKeys ...string) (members []string, err error)
- func (c Client) SINTERSTORE(destinationKey string, sourceKey string, otherKeys ...string) (count int64, err error)
- func (c Client) SISMEMBER(key string, member string) (ok bool, err error)
- func (c Client) SMEMBERS(key string) (members []string, err error)
- func (c Client) SMOVE(sourceKey string, destinationKey string, member string) (ok bool, err error)
- func (c Client) SPOP(key string, count int64) (members []string, err error)
- func (c Client) SRANDMEMBER(key string, count int64) (members []string, err error)
- func (c Client) SREM(key string, members ...string) (removedMembers []string, err error)
- func (c Client) SUNION(keys ...string) (members []string, err error)
- func (c Client) SUNIONSTORE(destinationKey string, sourceKeys ...string) (count int64, err error)
- func (c Client) XACK(key string, group string, ids ...XID) (acknowledgedIds []XID, err error)
- func (c Client) XADD(key string, id XID, fields map[string]Value) (returnedID XID, err error)
- func (c Client) XCLAIM(key string, group string, consumer string, lastDeliveredBefore time.Time, ...) (items []StreamItem, err error)
- func (c Client) XDEL(key string, ids ...XID) (deletedItems []XID, err error)
- func (c Client) XGROUP(key string, group string, start XID) (err error)
- func (c Client) XLEN(key string, start, stop XID) (count int64, err error)
- func (c Client) XPENDING(key string, group string, count int64) (pendingItems []PendingItem, err error)
- func (c Client) XRANGE(key string, start, stop XID, count int64) (streamItems []StreamItem, err error)
- func (c Client) XREAD(key string, from XID, count int64) (items []StreamItem, err error)
- func (c Client) XREADGROUP(key string, group string, consumer string, option XReadOption, maxCount int64) (items []StreamItem, err error)
- func (c Client) XREVRANGE(key string, end, start XID, count int64) (streamItems []StreamItem, err error)
- func (c Client) XTRIM(key string, newCount int64) (deletedCount int64, err error)
- func (c Client) ZADD(key string, membersWithScores map[string]float64, flags Flags) (addedMembers []string, err error)
- func (c Client) ZCARD(key string) (count int64, err error)
- func (c Client) ZCOUNT(key string, minScore, maxScore float64) (count int64, err error)
- func (c Client) ZINCRBY(key string, member string, delta float64) (newScore float64, err error)
- func (c Client) ZINTER(sourceKeys []string, aggregation ZAggregation, weights map[string]float64) (membersWithScores map[string]float64, err error)
- func (c Client) ZINTERSTORE(destinationKey string, sourceKeys []string, aggregation ZAggregation, ...) (membersWithScores map[string]float64, err error)
- func (c Client) ZLEXCOUNT(key string, min string, max string) (count int64, err error)
- func (c Client) ZPOPMAX(key string, count int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZPOPMIN(key string, count int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZRANGE(key string, start, stop int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZRANGEBYLEX(key string, min, max string, offset, count int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZRANGEBYSCORE(key string, min, max float64, offset, count int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZRANK(key string, member string) (rank int64, found bool, err error)
- func (c Client) ZREM(key string, members ...string) (removedMembers []string, err error)
- func (c Client) ZREMRANGEBYLEX(key string, min, max string) (removedMembers []string, err error)
- func (c Client) ZREMRANGEBYRANK(key string, start, stop int64) (removedMembers []string, err error)
- func (c Client) ZREMRANGEBYSCORE(key string, min, max float64) (removedMembers []string, err error)
- func (c Client) ZREVRANGE(key string, start, stop int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZREVRANGEBYLEX(key string, max, min string, offset, count int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZREVRANGEBYSCORE(key string, max, min float64, offset, count int64) (membersWithScores map[string]float64, err error)
- func (c Client) ZREVRANK(key string, member string) (rank int64, found bool, err error)
- func (c Client) ZSCORE(key string, member string) (score float64, found bool, err error)
- func (c Client) ZUNION(sourceKeys []string, aggregation ZAggregation, weights map[string]float64) (membersWithScores map[string]float64, err error)
- func (c Client) ZUNIONSTORE(destinationKey string, sourceKeys []string, aggregation ZAggregation, ...) (membersWithScores map[string]float64, err error)
- type Flag
- type Flags
- type FloatValue
- type GLocation
- type GUnit
- type IntValue
- type LSide
- type PendingItem
- type ReturnValue
- func (rv ReturnValue) Bytes() []byte
- func (rv ReturnValue) Empty() bool
- func (rv ReturnValue) Equals(ov ReturnValue) bool
- func (rv ReturnValue) Float() float64
- func (rv ReturnValue) Int() int64
- func (rv ReturnValue) Present() bool
- func (rv ReturnValue) String() string
- func (rv ReturnValue) ToAV() dynamodb.AttributeValue
- type StreamItem
- type StringValue
- type Value
- type XID
- type XReadOption
- type ZAggregation
Constants ¶
This section is empty.
Variables ¶
var ErrXGroupNotInitialized = errors.New("group not initialized")
Functions ¶
This section is empty.
Types ¶
type BytesValue ¶
type BytesValue struct {
B []byte
}
func (BytesValue) ToAV ¶ added in v0.2.0
func (bv BytesValue) ToAV() dynamodb.AttributeValue
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (Client) GEORADIUSBYMEMBER ¶
func (Client) GET ¶
func (c Client) GET(key string) (val ReturnValue, err error)
GET fetches the value at the given key. If the key does not exist, the ReturnValue will be Empty().
Works similar to https://redis.io/commands/get
func (Client) GETSET ¶
func (c Client) GETSET(key string, value Value) (oldValue ReturnValue, err error)
GETSET gets the value at the key and atomically sets it to a new value.
Works similar to https://redis.io/commands/getset
func (Client) HGETALL ¶
func (c Client) HGETALL(key string) (fieldValues map[string]ReturnValue, err error)
func (Client) HINCRBYFLOAT ¶
func (Client) INCRBYFLOAT ¶
func (Client) LINDEX ¶
func (c Client) LINDEX(key string, index int64) (element ReturnValue, err error)
func (Client) LINSERT ¶
func (c Client) LINSERT(key string, side LSide, pivot, element Value) (newLength int64, done bool, err error)
LINSERT inserts the given element on the given side of the pivot element.
func (Client) LRANGE ¶
func (c Client) LRANGE(key string, start, stop int64) (elements []ReturnValue, err error)
func (Client) MGET ¶
func (c Client) MGET(keys ...string) (values map[string]ReturnValue, err error)
MGET fetches the given keys atomically in a transaction. The call is limited to 25 keys and 4MB. See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactGetItems.html
Works similar to https://redis.io/commands/mget
func (Client) MSET ¶
MSET sets the given keys and values atomically in a transaction. The call is limited to 25 keys and 4MB. See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html
Works similar to https://redis.io/commands/mset
func (Client) MSETNX ¶
MSETNX sets the given keys and values atomically in a transaction, but only if none of the given keys exist. If one or more of the keys already exist, nothing will be changed and MSETNX will return false.
Works similar to https://redis.io/commands/msetnx
func (Client) RPOPLPUSH ¶
func (c Client) RPOPLPUSH(sourceKey string, destinationKey string) (element ReturnValue, err error)
func (Client) SDIFFSTORE ¶
func (Client) SET ¶
SET stores the given Value at the given key. If called as SET("key", "value", None), SET is unconditional and is not expected to fail.
The condition flags IfNotExists and IfAlreadyExists can be specified, and if they are the SET becomes conditional and will return false if the condition fails.
Works similar to https://redis.io/commands/set
func (Client) SETNX ¶
SETNX is equivalent to SET(key, value, Flags{IfNotExists})
Works similar to https://redis.io/commands/setnx
func (Client) SINTERSTORE ¶
func (Client) SRANDMEMBER ¶
func (Client) SUNIONSTORE ¶
func (Client) XADD ¶
XADD adds the given fields as a item on the stream at key. If the stream does not exist, it will be initialized.
If the XID passed in is XAutoID, an ID will be automatically generated on the current time and a sequence generator.
Note that if you pass in your own ID, the stream will never allow you to insert an item with an ID less than the greatest ID present in the stream – the stream can only move forwards. This guarantees that if you've read entries up to a given XID using XREAD, you can always continue reading from that last XID without fear of missing anything, because the IDs are always increasing.
Works similar to https://redis.io/commands/xadd
func (Client) XDEL ¶
XDEL removes the given IDs and returns the IDs that were actually deleted as part of this operation.
Note that this operation is not atomic across given IDs – it's possible that an error is returned based on a problem deleting one of the IDs when the others have been deleted. Even when an error is returned, the items that were deleted will still be populated.
Works similar to https://redis.io/commands/xdel
func (Client) XRANGE ¶
func (c Client) XRANGE(key string, start, stop XID, count int64) (streamItems []StreamItem, err error)
XRANGE fetches the stream records between two XIDs, inclusive of both the start and end IDs, limited to the count.
If you receive the entire count you've asked for, it's reasonable to suppose there might be more items in the given range that were not returned because they would exceed the count – in this case you can call the XID.Next() method on the last received stream ID for an XID to use as the start of the next call.
Common uses include fetching a single item based on XID, which would be
XRANGE(key, id, id, 1)
or fetching records in the month of February, like
XRANGE(key, NewTimeXID(beginningOfFebruary).First(), NewTimeXID(endOfFebruary).Last(), 1000) XRANGE(key, NewTimeXID(beginningOfFebruary).First(), NewTimeXID(beginningOfMarch).First(), 1000)
Note that the two calls are equivalent, because this operation uses the DynamoDB BETWEEN operator, which translates to
start <= id <= end
There is are no offset or pagination parameters required, because when the full count is hit the next page of items can be fetched as follows:
XRANGE(key, lastFetchedItemID.Next(), NewTimeXID(endOfFebruary).Last(), 1000)
See the XID docs for more information on how to generate start and stop XIDs based on time.
Works similar to https://redis.io/commands/xrange
func (Client) XREAD ¶
XREAD reads items sequentially from a stream. The structure of a stream guarantees that the XIDs are always increasing. This implies that calling XREAD in a loop and passing in the XID of the last item read will allow iteration over all items reliably.
To start reading a stream from the beginning, use the special XStart XID.
Works similar to https://redis.io/commands/xread
func (Client) XREADGROUP ¶
func (c Client) XREADGROUP(key string, group string, consumer string, option XReadOption, maxCount int64) (items []StreamItem, err error)
func (Client) XREVRANGE ¶
func (c Client) XREVRANGE(key string, end, start XID, count int64) (streamItems []StreamItem, err error)
XREVRANGE is similar to XRANGE, but in reverse order. The stream items in descending chronological order. Using the same example as XRANGE, when fetching items in reverse order there are some differences when paginating. The first set of records can be fetched using:
XRANGE(key, NewTimeXID(endOfFebruary).Last(), NewTimeXID(beginningOfFebruary).First(), 1000)
he next page can be fetched using
XRANGE(key, lastFetchedItemID.Prev(), NewTimeXID(beginningOfFebruary).First(), 1000)
Works similar to https://redis.io/commands/xrevrange
func (Client) ZINTERSTORE ¶
func (Client) ZRANGEBYLEX ¶
func (Client) ZRANGEBYSCORE ¶
func (Client) ZREMRANGEBYLEX ¶
func (Client) ZREMRANGEBYRANK ¶
func (Client) ZREMRANGEBYSCORE ¶
func (Client) ZREVRANGEBYLEX ¶
func (Client) ZREVRANGEBYSCORE ¶
type FloatValue ¶ added in v0.2.0
type FloatValue struct {
F float64
}
func (FloatValue) ToAV ¶ added in v0.2.0
func (fv FloatValue) ToAV() dynamodb.AttributeValue
type GLocation ¶ added in v0.2.0
func (GLocation) DistanceTo ¶ added in v0.2.0
type IntValue ¶ added in v0.2.0
type IntValue struct {
I int64
}
func (IntValue) ToAV ¶ added in v0.2.0
func (iv IntValue) ToAV() dynamodb.AttributeValue
type PendingItem ¶
type ReturnValue ¶ added in v0.2.0
type ReturnValue struct {
// contains filtered or unexported fields
}
ReturnValue holds a value returned by Redimo. There are convenience methods used to coerce the held value into common types, but you can also retrieve the raw dynamodb.AttributeValue by calling ToAV if you would like to do custom decoding.
func (ReturnValue) Bytes ¶ added in v0.2.0
func (rv ReturnValue) Bytes() []byte
func (ReturnValue) Empty ¶ added in v0.2.0
func (rv ReturnValue) Empty() bool
func (ReturnValue) Equals ¶ added in v0.2.0
func (rv ReturnValue) Equals(ov ReturnValue) bool
func (ReturnValue) Float ¶ added in v0.2.0
func (rv ReturnValue) Float() float64
func (ReturnValue) Int ¶ added in v0.2.0
func (rv ReturnValue) Int() int64
func (ReturnValue) Present ¶ added in v0.2.0
func (rv ReturnValue) Present() bool
func (ReturnValue) String ¶ added in v0.2.0
func (rv ReturnValue) String() string
func (ReturnValue) ToAV ¶ added in v0.2.0
func (rv ReturnValue) ToAV() dynamodb.AttributeValue
type StreamItem ¶
type StreamItem struct { ID XID Fields map[string]ReturnValue }
type StringValue ¶
type StringValue struct {
S string
}
func (StringValue) ToAV ¶ added in v0.2.0
func (sv StringValue) ToAV() dynamodb.AttributeValue
type Value ¶
type Value interface {
ToAV() dynamodb.AttributeValue
}
Value allows you to store values of any type supported by DynamoDB, as long as they implement this interface and encode themselves into the dynamodb.AttributeValue returned by ToAV.
Some common value wrappers are provided, like StringValue, FloatValue, IntValue and BytesValue. The output of most operations is a ReturnValue which has convenience methods to decode the data into these common types.
You can implement the ToAV() method on any type that you would like to provide a custom encoding for. When you receive the data wrapped in a ReturnValue, the ToAV method can be used to access the raw dynamo.AttributeValue struct, allowing you to do custom deserialization.
type XID ¶
type XID string
XID holds a stream item ID, and consists of a timestamp (one second resolution) and a sequence number.
Most code will not need to generate XIDs – using XAutoID with XADD is the most common usage. But if you do need to generate XIDs for insertion with XADD, the NewXID methods creates a complete XID.
To generate time based XIDs for time range queries with XRANGE or XREVRANGE, use NewTimeXID(startTime).First() and NewTimeXID(endTime).Last(). Calling Last() is especially important because without it none of the items in the last second of the range will match – you need the last possible sequence number in the last second of the range, which is what the Last() method provides.
const XAutoID XID = "*"
const XEnd XID = "99999999999999999999-99999999999999999999"
const XStart XID = "00000000000000000000-00000000000000000000"
func NewTimeXID ¶ added in v0.5.0
NewTimeXID creates an XID with the given timestamp. To get the first or the last XID in this timestamp, use the First() or the Last() methods. This is especially important when using constructed XIDs inside a range call like XRANGE or XREVRANGE.
func (XID) First ¶ added in v0.5.0
First returns the first valid XID at this timestamp. Useful for the start parameter of XRANGE or XREVRANGE.
func (XID) Last ¶ added in v0.5.0
Last returns the last valid XID at this timestamp. Useful for the end parameter of XRANGE or XREVRANGE. Note that if the XID used as an end in the range simply based on the timestamp, the sequence number will be zero, so the query will exclude all the items in end second. This will effectively transform the query to '< endTime' instead of '<= endTime'. Using Last() prevents this mistake, if that is your intention.
func (XID) Next ¶
Next returns the next valid XID at the same time – it simply returns a new XID with the next sequence number.
type XReadOption ¶
type XReadOption string
const ( XReadPending XReadOption = "PENDING" XReadNew XReadOption = "READ_NEW" XReadNewAutoACK XReadOption = "READ_NEW_NO_ACK" )
type ZAggregation ¶ added in v0.2.0
type ZAggregation string
const ( ZAggregationSum ZAggregation = "SUM" ZAggregationMin ZAggregation = "MIN" ZAggregationMax ZAggregation = "MAX" )