How can I retrieve a list of subkeys, branch of master key #51
-
Hi, thanks for your greate job, its really helpfull and easy to use. How can I retrieve a list of subkeys from pattern key (userid:*), then I need to delete all that sub tree keys from redis server. var result = await Process.run(
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Have you tried with redis command KEYS |
Beta Was this translation helpful? Give feedback.
-
Oh. I see! Do you have trouble using scan? Something like - without compiler var iter = "0"
do{
r = await _cache.send_object(['scan',iter, 'MATCH','userId:$userId:*');
iter = r[0]; // update new iterator
var keys = r[1];
// delete keys for received range
for (var i = 0; i < keys.length; i++) {
await _cache.send_object(['EXPIRE', '${keys[i]}', '-1']);
}
} while(iter != "0"); |
Beta Was this translation helpful? Give feedback.
Oh. I see! Do you have trouble using scan?
Something like - without compiler