B
B
Bone2021-06-23 11:27:47
Redis
Bone, 2021-06-23 11:27:47

How to bulk update keys of the same type?

Hello! Previously, I practically did not work with radish. The question is this: there are many entries in the database like user:1:followers, user:2:followers, and so on. How do I efficiently reset the values ​​of all such keys to null? So that user:1:followers = user:2:followers = ... = 0
Is it possible to write something like SET user:*:followers 0?
In addition to followers, friends must also be reset. Can these operations be combined somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Romses Panagiotis, 2021-06-23
@Bone

You can scan the keys with the SCAN command with an asterisk in the template and reset the values ​​using the found keys with the MSET command.
If it is possible with one team, I will be glad to know too.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question