简体   繁体   中英

How to clear values of keys in redis

I am running two instance of my php application, one is live and one is beta. i am using redis in my live server for caching data. i am storing article category as key and article id as values.

Recently by mistake i connected my beta server with the redis and it has messed redis cache. i mean it has added some other article ids in wrong keys. so now i started getting wrong data from redis.

my question is

"is there any way to clear only values of the redis keys?"

i don't want to clear keys but only values of it.

i had gone through redis document and i found flushAll , del etc.. but based on doc it will delete my keys also it seems.

i am using predis php library to communicate with redis server.

can anybody help me to delete only values from redis server.

When you "clear" the value of a key, Redis will remove the key. Put differently, you can't have keys with no values.

尝试使用此功能

$redis->mset(array('key0' => '', 'key1' => ''));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM