简体   繁体   English

在Stackexchange.Redis中获取Redis前缀的所有键(字符串类型)

[英]Get all keys (string type) with prefix from Redis in Stackexchange.Redis

I have a scenario where I have to get all the keys (string type) matching some prefix. 我有一个场景,我必须得到匹配一些前缀的所有键(字符串类型)。 For example, I have below keys 例如,我有以下键

 1. ABC.10
 2. ABC.11
 3. ABC.12 
 4. XYZ.10
 5. XYZ.11
 6. XYZ.12

And I need to get all keys matching XYZ using Stackexchange.Redis C#. 我需要使用Stackexchange.Redis C#获取所有与XYZ匹配的键。

I found the way out to get the keys from Redis 我找到了从Redis获取钥匙的方法

 ConnectionMultiplexer con = RedisConnectionFactory.GetConnection();
 IServer server = con.GetServer("redisdb:6379");
  foreach (var key in server.Keys(DB_Number, "XYZ.*", 1000))
 {
   //logic
 }

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

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