Skip to content

Commit

Permalink
Merge branch 'main' into go/xgroupdestroy
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Jan 21, 2025
2 parents b527896 + 4050baf commit bedac71
Show file tree
Hide file tree
Showing 12 changed files with 608 additions and 680 deletions.
217 changes: 158 additions & 59 deletions go/api/base_client.go

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions go/api/generic_base_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,17 @@ type GenericBaseCommands interface {
// key - string
//
// Return value:
// If the key exists, the type of the stored value is returned. Otherwise, a none" string is returned.
// If the key exists, the type of the stored value is returned. Otherwise, a "none" string is returned.
//
// Example:
// result, err := client.Type([]string{"key"})
// if err != nil {
// // handle error
// }
// fmt.Println(result.Value()) // Output: string
// fmt.Println(result) // Output: string
//
// [valkey.io]: Https://valkey.io/commands/type/
Type(key string) (Result[string], error)
Type(key string) (string, error)

// Renames key to new key.
// If new Key already exists it is overwritten.
Expand All @@ -399,10 +399,10 @@ type GenericBaseCommands interface {
// if err != nil {
// // handle error
// }
// fmt.Println(result.Value()) // Output: OK
// fmt.Println(result) // Output: OK
//
// [valkey.io]: https://valkey.io/commands/rename/
Rename(key string, newKey string) (Result[string], error)
Rename(key string, newKey string) (string, error)

// Renames key to newkey if newKey does not yet exist.
//
Expand Down Expand Up @@ -613,11 +613,10 @@ type GenericBaseCommands interface {
// Example:
//
// result, err := client.SortStore("key","destkey")
// result.Value(): 1
// result.IsNil(): false
// result: 1
//
// [valkey.io]: https://valkey.io/commands/sort/
SortStore(key string, destination string) (Result[int64], error)
SortStore(key string, destination string) (int64, error)

// Sorts the elements in the list, set, or sorted set at key and stores the result in
// destination. The sort command can be used to sort elements based on
Expand Down Expand Up @@ -648,11 +647,10 @@ type GenericBaseCommands interface {
//
// options := api.NewSortOptions().SetByPattern("weight_*").SetIsAlpha(false).AddGetPattern("object_*").AddGetPattern("#")
// result, err := client.SortStore("key","destkey",options)
// result.Value(): 1
// result.IsNil(): false
// result: 1
//
// [valkey.io]: https://valkey.io/commands/sort/
SortStoreWithOptions(key string, destination string, sortOptions *options.SortOptions) (Result[int64], error)
SortStoreWithOptions(key string, destination string, sortOptions *options.SortOptions) (int64, error)

// Sorts the elements in the list, set, or sorted set at key and returns the result.
// The sortReadOnly command can be used to sort elements based on different criteria and apply
Expand Down
2 changes: 1 addition & 1 deletion go/api/glide_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (client *glideClient) ConfigSet(parameters map[string]string) (string, erro
return handleStringResponse(result)
}

func (client *glideClient) ConfigGet(args []string) (map[Result[string]]Result[string], error) {
func (client *glideClient) ConfigGet(args []string) (map[string]string, error) {
res, err := client.executeCommand(C.ConfigGet, args)
if err != nil {
return nil, err
Expand Down
25 changes: 8 additions & 17 deletions go/api/hash_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ type HashCommands interface {
//
// For example:
// fieldValueMap, err := client.HGetAll("my_hash")
// // field1 equals api.CreateStringResult("field1")
// // value1 equals api.CreateStringResult("value1")
// // field2 equals api.CreateStringResult("field2")
// // value2 equals api.CreateStringResult("value2")
// // fieldValueMap equals map[api.Result[string]]api.Result[string]{field1: value1, field2: value2}
// // fieldValueMap equals map[string]string{field1: value1, field2: value2}
//
// [valkey.io]: https://valkey.io/commands/hgetall/
HGetAll(key string) (map[Result[string]]Result[string], error)
HGetAll(key string) (map[string]string, error)

// HMGet returns the values associated with the specified fields in the hash stored at key.
//
Expand Down Expand Up @@ -172,17 +168,14 @@ type HashCommands interface {
// key - The key of the hash.
//
// Return value:
// A slice of Result[string]s containing all the values in the hash, or an empty slice when key does not exist.
// A slice containing all the values in the hash, or an empty slice when key does not exist.
//
// For example:
// values, err := client.HVals("myHash")
// // value1 equals api.CreateStringResult("value1")
// // value2 equals api.CreateStringResult("value2")
// // value3 equals api.CreateStringResult("value3")
// // values equals []api.Result[string]{value1, value2, value3}
// values: []string{"value1", "value2", "value3"}
//
// [valkey.io]: https://valkey.io/commands/hvals/
HVals(key string) ([]Result[string], error)
HVals(key string) ([]string, error)

// HExists returns if field is an existing field in the hash stored at key.
//
Expand Down Expand Up @@ -215,16 +208,14 @@ type HashCommands interface {
// key - The key of the hash.
//
// Return value:
// A slice of Result[string]s containing all the field names in the hash, or an empty slice when key does not exist.
// A slice containing all the field names in the hash, or an empty slice when key does not exist.
//
// For example:
// names, err := client.HKeys("my_hash")
// // field1 equals api.CreateStringResult("field_1")
// // field2 equals api.CreateStringResult("field_2")
// // names equals []api.Result[string]{field1, field2}
// names: []string{"field1", "field2"}
//
// [valkey.io]: https://valkey.io/commands/hkeys/
HKeys(key string) ([]Result[string], error)
HKeys(key string) ([]string, error)

// HStrLen returns the string length of the value associated with field in the hash stored at key.
// If the key or the field do not exist, 0 is returned.
Expand Down
72 changes: 34 additions & 38 deletions go/api/list_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type ListCommands interface {
// result: nil
//
// [valkey.io]: https://valkey.io/commands/lpop/
LPopCount(key string, count int64) ([]Result[string], error)
LPopCount(key string, count int64) ([]string, error)

// Returns the index of the first occurrence of element inside the list specified by key. If no match is found,
// [api.CreateNilInt64Result()] is returned.
Expand Down Expand Up @@ -132,13 +132,12 @@ type ListCommands interface {
// An array that holds the indices of the matching elements within the list.
//
// For example:
// result, err := client.RPush("my_list", []string{"a", "b", "c", "d", "e", "e", "e"})
// _, err := client.RPush("my_list", []string{"a", "b", "c", "d", "e", "e", "e"})
// result, err := client.LPosCount("my_list", "e", int64(3))
// result: []api.Result[int64]{api.CreateInt64Result(4), api.CreateInt64Result(5), api.CreateInt64Result(6)}
//
// result: []int64{ 4, 5, 6 }
//
// [valkey.io]: https://valkey.io/commands/lpos/
LPosCount(key string, element string, count int64) ([]Result[int64], error)
LPosCount(key string, element string, count int64) ([]int64, error)

// Returns an array of indices of matching elements within a list based on the given options. If no match is found, an
// empty array is returned.
Expand All @@ -155,21 +154,21 @@ type ListCommands interface {
// An array that holds the indices of the matching elements within the list.
//
// For example:
// 1. result, err := client.RPush("my_list", []string{"a", "b", "c", "d", "e", "e", "e"})
// 1. _, err := client.RPush("my_list", []string{"a", "b", "c", "d", "e", "e", "e"})
// result, err := client.LPosWithOptions("my_list", "e", int64(1), api.NewLPosOptionsBuilder().SetRank(2))
// result: []api.Result[int64]{api.CreateInt64Result(5)}
// 2. result, err := client.RPush("my_list", []string{"a", "b", "c", "d", "e", "e", "e"})
// result: []int64{ 5 }
// 2. _, err := client.RPush("my_list", []string{"a", "b", "c", "d", "e", "e", "e"})
// result, err := client.LPosWithOptions(
// "my_list",
// "e",
// int64(3),
// api.NewLPosOptionsBuilder().SetRank(2).SetMaxLen(1000),
// )
// result: []api.Result[int64]{api.CreateInt64Result(5), api.CreateInt64Result(6)}
// result: []int64{ 5, 6 }
//
//
// [valkey.io]: https://valkey.io/commands/lpos/
LPosCountWithOptions(key string, element string, count int64, options *LPosOptions) ([]Result[int64], error)
LPosCountWithOptions(key string, element string, count int64, options *LPosOptions) ([]int64, error)

// Inserts all the specified values at the tail of the list stored at key.
// elements are inserted one after the other to the tail of the list, from the leftmost element to the rightmost element.
Expand Down Expand Up @@ -211,15 +210,14 @@ type ListCommands interface {
//
// For example:
// 1. result, err := client.LRange("my_list", 0, 2)
// result: []api.Result[string]{api.CreateStringResult("value1"), api.CreateStringResult("value2"),
// api.CreateStringResult("value3")}
// result: []string{ "value1", "value2", "value3" }
// 2. result, err := client.LRange("my_list", -2, -1)
// result: []api.Result[string]{api.CreateStringResult("value2"), api.CreateStringResult("value3")}
// result: []string{ "value2", "value3" }
// 3. result, err := client.LRange("non_existent_key", 0, 2)
// result: []api.Result[string]{}
// result: []string{}
//
// [valkey.io]: https://valkey.io/commands/lrange/
LRange(key string, start int64, end int64) ([]Result[string], error)
LRange(key string, start int64, end int64) ([]string, error)

// Returns the element at index from the list stored at key.
// The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to
Expand Down Expand Up @@ -357,7 +355,7 @@ type ListCommands interface {
// result: nil
//
// [valkey.io]: https://valkey.io/commands/rpop/
RPopCount(key string, count int64) ([]Result[string], error)
RPopCount(key string, count int64) ([]string, error)

// Inserts element in the list at key either before or after the pivot.
//
Expand Down Expand Up @@ -397,17 +395,17 @@ type ListCommands interface {
// timeoutSecs - The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.
//
// Return value:
// A two-element array of Result[string] containing the key from which the element was popped and the value of the popped
// A two-element array containing the key from which the element was popped and the value of the popped
// element, formatted as [key, value].
// If no element could be popped and the timeout expired, returns nil.
// If no element could be popped and the timeout expired, returns `nil`.
//
// For example:
// result, err := client.BLPop("list1", "list2", 0.5)
// result: []api.Result[string]{api.CreateStringResult("list1"), api.CreateStringResult("element")}
// result: []string{ "list1", "element" }
//
// [valkey.io]: https://valkey.io/commands/blpop/
// [Blocking Commands]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands
BLPop(keys []string, timeoutSecs float64) ([]Result[string], error)
BLPop(keys []string, timeoutSecs float64) ([]string, error)

// Pops an element from the tail of the first list that is non-empty, with the given keys being checked in the order that
// they are given.
Expand All @@ -424,17 +422,17 @@ type ListCommands interface {
// timeoutSecs - The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.
//
// Return value:
// A two-element array of Result[string] containing the key from which the element was popped and the value of the popped
// A two-element array containing the key from which the element was popped and the value of the popped
// element, formatted as [key, value].
// If no element could be popped and the timeoutSecs expired, returns nil.
// If no element could be popped and the timeoutSecs expired, returns `nil`.
//
// For example:
// result, err := client.BRPop("list1", "list2", 0.5)
// result: []api.Result[string]{api.CreateStringResult("list1"), api.CreateStringResult("element")}
// result: []string{ "list1", "element" }
//
// [valkey.io]: https://valkey.io/commands/brpop/
// [Blocking Commands]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands
BRPop(keys []string, timeoutSecs float64) ([]Result[string], error)
BRPop(keys []string, timeoutSecs float64) ([]string, error)

// Inserts all the specified values at the tail of the list stored at key, only if key exists and holds a list. If key is
// not a list, this performs no operation.
Expand Down Expand Up @@ -493,10 +491,10 @@ type ListCommands interface {
// For example:
// result, err := client.LPush("my_list", []string{"one", "two", "three"})
// result, err := client.LMPop([]string{"my_list"}, api.Left)
// result[api.CreateStringResult("my_list")] = []api.Result[string]{api.CreateStringResult("three")}
// result["my_list"] = []string{"three"}
//
// [valkey.io]: https://valkey.io/commands/lmpop/
LMPop(keys []string, listDirection ListDirection) (map[Result[string]][]Result[string], error)
LMPop(keys []string, listDirection ListDirection) (map[string][]string, error)

// Pops one or more elements from the first non-empty list from the provided keys.
//
Expand All @@ -516,10 +514,10 @@ type ListCommands interface {
// For example:
// result, err := client.LPush("my_list", []string{"one", "two", "three"})
// result, err := client.LMPopCount([]string{"my_list"}, api.Left, int64(1))
// result[api.CreateStringResult("my_list")] = []api.Result[string]{api.CreateStringResult("three")}
// result["my_list"] = []string{"three"}
//
// [valkey.io]: https://valkey.io/commands/lmpop/
LMPopCount(keys []string, listDirection ListDirection, count int64) (map[Result[string]][]Result[string], error)
LMPopCount(keys []string, listDirection ListDirection, count int64) (map[string][]string, error)

// Blocks the connection until it pops one element from the first non-empty list from the provided keys. BLMPop is the
// blocking variant of [api.LMPop].
Expand All @@ -546,11 +544,11 @@ type ListCommands interface {
// For example:
// result, err := client.LPush("my_list", []string{"one", "two", "three"})
// result, err := client.BLMPop([]string{"my_list"}, api.Left, float64(0.1))
// result[api.CreateStringResult("my_list")] = []api.Result[string]{api.CreateStringResult("three")}
// result["my_list"] = []string{"three"}
//
// [valkey.io]: https://valkey.io/commands/blmpop/
// [Blocking Commands]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands
BLMPop(keys []string, listDirection ListDirection, timeoutSecs float64) (map[Result[string]][]Result[string], error)
BLMPop(keys []string, listDirection ListDirection, timeoutSecs float64) (map[string][]string, error)

// Blocks the connection until it pops one or more elements from the first non-empty list from the provided keys.
// BLMPopCount is the blocking variant of [api.LMPopCount].
Expand Down Expand Up @@ -578,7 +576,7 @@ type ListCommands interface {
// For example:
// result, err: client.LPush("my_list", []string{"one", "two", "three"})
// result, err := client.BLMPopCount([]string{"my_list"}, api.Left, int64(1), float64(0.1))
// result[api.CreateStringResult("my_list")] = []api.Result[string]{api.CreateStringResult("three")}
// result["my_list"] = []string{"three"}
//
// [valkey.io]: https://valkey.io/commands/blmpop/
// [Blocking Commands]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands
Expand All @@ -587,7 +585,7 @@ type ListCommands interface {
listDirection ListDirection,
count int64,
timeoutSecs float64,
) (map[Result[string]][]Result[string], error)
) (map[string][]string, error)

// Sets the list element at index to element.
// The index is zero-based, so 0 means the first element,1 the second element and so on. Negative indices can be used to
Expand Down Expand Up @@ -632,9 +630,8 @@ type ListCommands interface {
// result.Value(): "one"
// updatedList1, err: client.LRange("my_list1", int64(0), int64(-1))
// updatedList2, err: client.LRange("my_list2", int64(0), int64(-1))
// updatedList1: []api.Result[string]{api.CreateStringResult("two")}
// updatedList2: []api.Result[string]{api.CreateStringResult("one"), api.CreateStringResult("three"),
// api.CreateStringResult("four")}
// updatedList1: []string{ "two" }
// updatedList2: []string{ "one", "three", "four" }
//
// [valkey.io]: https://valkey.io/commands/lmove/
LMove(source string, destination string, whereFrom ListDirection, whereTo ListDirection) (Result[string], error)
Expand Down Expand Up @@ -671,9 +668,8 @@ type ListCommands interface {
// result.Value(): "one"
// updatedList1, err: client.LRange("my_list1", int64(0), int64(-1))
// updatedList2, err: client.LRange("my_list2", int64(0), int64(-1))
// updatedList1: []api.Result[string]{api.CreateStringResult("two")}
// updatedList2: []api.Result[string]{api.CreateStringResult("one"), api.CreateStringResult("three"),
// api.CreateStringResult("four")}
// updatedList1: []string{ "two" }
// updatedList2: []string{ "one", "three", "four" }
//
// [valkey.io]: https://valkey.io/commands/blmove/
// [Blocking Commands]: https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands
Expand Down
Loading

0 comments on commit bedac71

Please sign in to comment.