0

Now I have lots of data in redis and each key has a few fields. I want the delete all the field with the same prefix like "one". And other fields withe different prefix like "two" or "three" should not be affected.

Does redis support this naturally and how can execute the command? Or which is the easily way for me to write the script to achieve this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
tobe
  • 1,671
  • 2
  • 23
  • 38
  • Look at the following for different methods to do that, depending on what you want to ensure (atomicity vs. performance): http://stackoverflow.com/a/23399125/3160475 – Itamar Haber Jan 29 '15 at 12:15
  • Thanks @ItamarHaber I will only clean the data for one time. But actually I just want to delete some prefix fields but not the entire key. – tobe Jan 29 '15 at 12:27
  • If you don't know the specific key names, use SCAN to get them. For each key, use HSCAN and delete per your pattern. – Itamar Haber Jan 29 '15 at 16:08
  • Thanks all and I have written a python script to get all data and delete the specified ones. – tobe Feb 02 '15 at 02:10

0 Answers0