4

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#.

3
  • stackoverflow.com/questions/26488830/… might help Commented Nov 23, 2017 at 7:06
  • @Vladimir, I tried the code I the link but getting below error Timeout performing SCAN, inst: 1, mgr: ProcessReadQueue, err: never, queue: 2, qu: 0, qs: 2, qc: 0, wr: 0, wq: 0, in: 7, ar: 1, clientName: ComputerName, serverEndpoint: Unspecified/redisCacheServer.com:6379, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=0,Free=32767,Min=8,Max=32767) (Please take a look at this article for some common client-side issues that can cause timeouts: stackexchange.github.io/StackExchange.Redis/Timeouts) Commented Nov 23, 2017 at 7:59
  • Mark your answer as the accepted answer. I was looking for something similar. Commented Dec 10, 2018 at 12:14

1 Answer 1

2

I found the way out to get the keys from Redis

 ConnectionMultiplexer con = RedisConnectionFactory.GetConnection();
 IServer server = con.GetServer("redisdb:6379");
  foreach (var key in server.Keys(DB_Number, "XYZ.*", 1000))
 {
   //logic
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.