@rivascva/dt-idl 1.1.160 → 1.1.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/go/redis/baserdb.go +7 -4
- package/package.json +1 -1
package/go/redis/baserdb.go
CHANGED
|
@@ -72,17 +72,17 @@ func (r *BaseRDB) Set(ctx context.Context, key string, value any) error {
|
|
|
72
72
|
|
|
73
73
|
func (r *BaseRDB) MSet(ctx context.Context, entries map[string]any) error {
|
|
74
74
|
// format the entries
|
|
75
|
-
|
|
75
|
+
args := make([]any, 0, len(entries)*2)
|
|
76
76
|
for key, value := range entries {
|
|
77
77
|
bytes, err := json.Marshal(value)
|
|
78
78
|
if err != nil {
|
|
79
79
|
return fmt.Errorf("failed to marshal the value for key %s: %w", key, err)
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
args = append(args, FormatKey(r.database, key), bytes)
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// set the entries in the redis client
|
|
85
|
-
err := r.client.MSet(ctx,
|
|
85
|
+
err := r.client.MSet(ctx, args...).Err()
|
|
86
86
|
if err != nil {
|
|
87
87
|
return fmt.Errorf("failed to set the entries in the redis client: %w", err)
|
|
88
88
|
}
|
|
@@ -197,7 +197,7 @@ func (r *BaseRDB) GetKeysWithPattern(ctx context.Context, pattern string, window
|
|
|
197
197
|
|
|
198
198
|
for {
|
|
199
199
|
// scan the database for keys matching the given pattern
|
|
200
|
-
keys,
|
|
200
|
+
keys, nextCursor, err := r.client.Scan(ctx, cursor, FormatKey(r.database, pattern), int64(window)).Result()
|
|
201
201
|
if err != nil {
|
|
202
202
|
return nil, fmt.Errorf("failed to scan the database: %w", err)
|
|
203
203
|
}
|
|
@@ -205,6 +205,9 @@ func (r *BaseRDB) GetKeysWithPattern(ctx context.Context, pattern string, window
|
|
|
205
205
|
// add the keys to the result
|
|
206
206
|
result = append(result, keys...)
|
|
207
207
|
|
|
208
|
+
// update the cursor
|
|
209
|
+
cursor = nextCursor
|
|
210
|
+
|
|
208
211
|
// if the cursor is 0, we have scanned all the keys
|
|
209
212
|
if cursor == 0 {
|
|
210
213
|
break
|