@@ -10,7 +10,6 @@ import "github.com/valkey-io/valkey-glide/go/glide/api/options"
1010//
1111// [valkey.io]: https://valkey.io/commands/?group=Generic
1212type GenericBaseCommands interface {
13-
1413 Del (keys []string ) (int64 , error )
1514
1615 Exists (keys []string ) (int64 , error )
@@ -43,97 +42,20 @@ type GenericBaseCommands interface {
4342
4443 Touch (keys []string ) (int64 , error )
4544
46- Type (key string ) (Result [ string ] , error )
45+ Type (key string ) (string , error )
4746
48- Rename (key string , newKey string ) (Result [ string ] , error )
47+ Rename (key string , newKey string ) (string , error )
4948
5049 Renamenx (key string , newKey string ) (bool , error )
5150
5251 Persist (key string ) (bool , error )
5352
54- // Create a key associated with a value that is obtained by
55- // deserializing the provided serialized value (obtained via [valkey.io]: Https://valkey.io/commands/dump/).
56- //
57- // Parameters:
58- // key - The key to create.
59- // ttl - The expiry time (in milliseconds). If 0, the key will persist.
60- // value - The serialized value to deserialize and assign to key.
61- //
62- // Return value:
63- // Return OK if successfully create a key with a value </code>.
64- //
65- // Example:
66- // result, err := client.Restore("key",ttl, value)
67- // if err != nil {
68- // // handle error
69- // }
70- // fmt.Println(result.Value()) // Output: OK
71- //
72- // [valkey.io]: https://valkey.io/commands/restore/
7353 Restore (key string , ttl int64 , value string ) (Result [string ], error )
7454
75- // Create a key associated with a value that is obtained by
76- // deserializing the provided serialized value (obtained via [valkey.io]: Https://valkey.io/commands/dump/).
77- //
78- // Parameters:
79- // key - The key to create.
80- // ttl - The expiry time (in milliseconds). If 0, the key will persist.
81- // value - The serialized value to deserialize and assign to key.
82- // restoreOptions - Set restore options with replace and absolute TTL modifiers, object idletime and frequency
83- //
84- // Return value:
85- // Return OK if successfully create a key with a value.
86- //
87- // Example:
88- // restoreOptions := api.NewRestoreOptionsBuilder().SetReplace().SetABSTTL().SetEviction(api.FREQ, 10)
89- // resultRestoreOpt, err := client.RestoreWithOptions(key, ttl, value, restoreOptions)
90- // if err != nil {
91- // // handle error
92- // }
93- // fmt.Println(result.Value()) // Output: OK
94- //
95- // [valkey.io]: https://valkey.io/commands/restore/
9655 RestoreWithOptions (key string , ttl int64 , value string , option * RestoreOptions ) (Result [string ], error )
9756
98- // Returns the internal encoding for the Valkey object stored at key.
99- //
100- // Note:
101- // When in cluster mode, both key and newkey must map to the same hash slot.
102- //
103- // Parameters:
104- // The key of the object to get the internal encoding of.
105- //
106- // Return value:
107- // If key exists, returns the internal encoding of the object stored at
108- // key as a String. Otherwise, returns null.
109- //
110- // Example:
111- // result, err := client.ObjectEncoding("mykeyRenamenx")
112- // if err != nil {
113- // // handle error
114- // }
115- // fmt.Println(result.Value()) // Output: embstr
116- //
117- // [valkey.io]: https://valkey.io/commands/object-encoding/
11857 ObjectEncoding (key string ) (Result [string ], error )
11958
120- // Serialize the value stored at key in a Valkey-specific format and return it to the user.
121- //
122- // Parameters:
123- // The key to serialize.
124- //
125- // Return value:
126- // The serialized value of the data stored at key
127- // If key does not exist, null will be returned.
128- //
129- // Example:
130- // result, err := client.Dump([]string{"key"})
131- // if err != nil {
132- // // handle error
133- // }
134- // fmt.Println(result.Value()) // Output: (Serialized Value)
135- //
136- // [valkey.io]: https://valkey.io/commands/dump/
13759 Dump (key string ) (Result [string ], error )
13860
13961 ObjectFreq (key string ) (Result [int64 ], error )
@@ -142,173 +64,15 @@ type GenericBaseCommands interface {
14264
14365 ObjectRefCount (key string ) (Result [int64 ], error )
14466
145- // Sorts the elements in the list, set, or sorted set at key and returns the result.
146- // The sort command can be used to sort elements based on different criteria and apply
147- // transformations on sorted elements.
148- // To store the result into a new key, see the sortStore function.
149- //
150- // Parameters:
151- // key - The key of the list, set, or sorted set to be sorted.
152- //
153- // Return value:
154- // An Array of sorted elements.
155- //
156- // Example:
157- //
158- // result, err := client.Sort("key")
159- // result.Value(): [{1 false} {2 false} {3 false}]
160- // result.IsNil(): false
161- //
162- // [valkey.io]: https://valkey.io/commands/sort/
16367 Sort (key string ) ([]Result [string ], error )
16468
165- // Sorts the elements in the list, set, or sorted set at key and returns the result.
166- // The sort command can be used to sort elements based on different criteria and apply
167- // transformations on sorted elements.
168- // To store the result into a new key, see the sortStore function.
169- //
170- // Note:
171- // In cluster mode, if `key` map to different hash slots, the command
172- // will be split across these slots and executed separately for each. This means the command
173- // is atomic only at the slot level. If one or more slot-specific requests fail, the entire
174- // call will return the first encountered error, even though some requests may have succeeded
175- // while others did not. If this behavior impacts your application logic, consider splitting
176- // the request into sub-requests per slot to ensure atomicity.
177- // The use of SortOptions.byPattern and SortOptions.getPatterns in cluster mode is
178- // supported since Valkey version 8.0.
179- //
180- // Parameters:
181- // key - The key of the list, set, or sorted set to be sorted.
182- // sortOptions - The SortOptions type.
183- //
184- // Return value:
185- // An Array of sorted elements.
186- //
187- // Example:
188- //
189- // options := api.NewSortOptions().SetByPattern("weight_*").SetIsAlpha(false).AddGetPattern("object_*").AddGetPattern("#")
190- // result, err := client.Sort("key", options)
191- // result.Value(): [{Object_3 false} {c false} {Object_1 false} {a false} {Object_2 false} {b false}]
192- // result.IsNil(): false
193- //
194- // [valkey.io]: https://valkey.io/commands/sort/
19569 SortWithOptions (key string , sortOptions * options.SortOptions ) ([]Result [string ], error )
19670
197- // Sorts the elements in the list, set, or sorted set at key and stores the result in
198- // destination. The sort command can be used to sort elements based on
199- // different criteria, apply transformations on sorted elements, and store the result in a new key.
200- // The sort command can be used to sort elements based on different criteria and apply
201- // transformations on sorted elements.
202- // To get the sort result without storing it into a key, see the sort or sortReadOnly function.
203- //
204- // Note:
205- // In cluster mode, if `key` and `destination` map to different hash slots, the command
206- // will be split across these slots and executed separately for each. This means the command
207- // is atomic only at the slot level. If one or more slot-specific requests fail, the entire
208- // call will return the first encountered error, even though some requests may have succeeded
209- // while others did not. If this behavior impacts your application logic, consider splitting
210- // the request into sub-requests per slot to ensure atomicity.
211- //
212- // Parameters:
213- // key - The key of the list, set, or sorted set to be sorted.
214- // destination - The key where the sorted result will be stored.
215- //
216- // Return value:
217- // The number of elements in the sorted key stored at destination.
218- //
219- // Example:
220- //
221- // result, err := client.SortStore("key","destkey")
222- // result.Value(): 1
223- // result.IsNil(): false
224- //
225- // [valkey.io]: https://valkey.io/commands/sort/
226- SortStore (key string , destination string ) (Result [int64 ], error )
227-
228- // Sorts the elements in the list, set, or sorted set at key and stores the result in
229- // destination. The sort command can be used to sort elements based on
230- // different criteria, apply transformations on sorted elements, and store the result in a new key.
231- // The sort command can be used to sort elements based on different criteria and apply
232- // transformations on sorted elements.
233- // To get the sort result without storing it into a key, see the sort or sortReadOnly function.
234- //
235- // Note:
236- // In cluster mode, if `key` and `destination` map to different hash slots, the command
237- // will be split across these slots and executed separately for each. This means the command
238- // is atomic only at the slot level. If one or more slot-specific requests fail, the entire
239- // call will return the first encountered error, even though some requests may have succeeded
240- // while others did not. If this behavior impacts your application logic, consider splitting
241- // the request into sub-requests per slot to ensure atomicity.
242- // The use of SortOptions.byPattern and SortOptions.getPatterns
243- // in cluster mode is supported since Valkey version 8.0.
244- //
245- // Parameters:
246- // key - The key of the list, set, or sorted set to be sorted.
247- // destination - The key where the sorted result will be stored.
248- // sortOptions - The SortOptions type.
249- //
250- // Return value:
251- // The number of elements in the sorted key stored at destination.
252- //
253- // Example:
254- //
255- // options := api.NewSortOptions().SetByPattern("weight_*").SetIsAlpha(false).AddGetPattern("object_*").AddGetPattern("#")
256- // result, err := client.SortStore("key","destkey",options)
257- // result.Value(): 1
258- // result.IsNil(): false
259- //
260- // [valkey.io]: https://valkey.io/commands/sort/
261- SortStoreWithOptions (key string , destination string , sortOptions * options.SortOptions ) (Result [int64 ], error )
262-
263- // Sorts the elements in the list, set, or sorted set at key and returns the result.
264- // The sortReadOnly command can be used to sort elements based on different criteria and apply
265- // transformations on sorted elements.
266- // This command is routed depending on the client's ReadFrom strategy.
267- //
268- // Parameters:
269- // key - The key of the list, set, or sorted set to be sorted.
270- //
271- // Return value:
272- // An Array of sorted elements.
273- //
274- // Example:
275- //
276- // result, err := client.SortReadOnly("key")
277- // result.Value(): [{1 false} {2 false} {3 false}]
278- // result.IsNil(): false
279- //
280- // [valkey.io]: https://valkey.io/commands/sort/
71+ SortStore (key string , destination string ) (int64 , error )
72+
73+ SortStoreWithOptions (key string , destination string , sortOptions * options.SortOptions ) (int64 , error )
74+
28175 SortReadOnly (key string ) ([]Result [string ], error )
28276
283- // Sorts the elements in the list, set, or sorted set at key and returns the result.
284- // The sort command can be used to sort elements based on different criteria and apply
285- // transformations on sorted elements.
286- // This command is routed depending on the client's ReadFrom strategy.
287- //
288- // Note:
289- // In cluster mode, if `key` map to different hash slots, the command
290- // will be split across these slots and executed separately for each. This means the command
291- // is atomic only at the slot level. If one or more slot-specific requests fail, the entire
292- // call will return the first encountered error, even though some requests may have succeeded
293- // while others did not. If this behavior impacts your application logic, consider splitting
294- // the request into sub-requests per slot to ensure atomicity.
295- // The use of SortOptions.byPattern and SortOptions.getPatterns in cluster mode is
296- // supported since Valkey version 8.0.
297- //
298- // Parameters:
299- // key - The key of the list, set, or sorted set to be sorted.
300- // sortOptions - The SortOptions type.
301- //
302- // Return value:
303- // An Array of sorted elements.
304- //
305- // Example:
306- //
307- // options := api.NewSortOptions().SetByPattern("weight_*").SetIsAlpha(false).AddGetPattern("object_*").AddGetPattern("#")
308- // result, err := client.SortReadOnly("key", options)
309- // result.Value(): [{Object_3 false} {c false} {Object_1 false} {a false} {Object_2 false} {b false}]
310- // result.IsNil(): false
311- //
312- // [valkey.io]: https://valkey.io/commands/sort/
31377 SortReadOnlyWithOptions (key string , sortOptions * options.SortOptions ) ([]Result [string ], error )
31478}
0 commit comments