简体   繁体   English

如何清除Redis中的键值

[英]How to clear values of keys in redis

I am running two instance of my php application, one is live and one is beta. 我正在运行我的php应用程序的两个实例,一个是实时的,一个是beta。 i am using redis in my live server for caching data. 我在实时服务器中使用Redis缓存数据。 i am storing article category as key and article id as values. 我将文章类别存储为键,将文章ID存储为值。

Recently by mistake i connected my beta server with the redis and it has messed redis cache. 最近,我错误地将我的Beta服务器与Redis连接起来,它使Redis缓存混乱了。 i mean it has added some other article ids in wrong keys. 我的意思是它在错误的键中添加了其他一些文章ID。 so now i started getting wrong data from redis. 所以现在我开始从Redis获取错误的数据。

my question is 我的问题是

"is there any way to clear only values of the redis keys?" “有没有办法只清除redis键的值?”

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. 我已经通过了redis文档,发现了flushAlldel等。但是基于doc,它似乎也会删除我的密钥。

i am using predis php library to communicate with redis server. 我正在使用predis php库与Redis服务器进行通信。

can anybody help me to delete only values from redis server. 任何人都可以帮助我从Redis服务器中删除仅值。

When you "clear" the value of a key, Redis will remove the key. 当您“清除”密钥的值时,Redis将删除密钥。 Put differently, you can't have keys with no values. 换句话说,您不能拥有没有值的键。

尝试使用此功能

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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