Redis / Jedis - 按模式删除? [英] Redis/Jedis - Delete by pattern?

查看:177
本文介绍了Redis / Jedis - 按模式删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我得到密钥集,然后使用外观删除每个键/值对。

Normally, I get the key set then use a look to delete each key/value pair.

是否可以通过模式删除所有密钥?

Is it possible to just delete all keys via pattern?

ie:

Del sample_pattern:*


推荐答案

看来,对于Jedis来说,按模式删除基本上是获取所有密钥然后循环通过它。

It seems, for Jedis, to "delete by pattern" is basically getting all the keys of a specific pattern then loop through it.

ie

Set<String> keys = jedis.keys(pattern);
for (String key : keys) {
    jedis.del(key);
} 

这篇关于Redis / Jedis - 按模式删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆