Reputation: 48
How do I find all the records in Redis?
USER_EXCHANGE = table
USER_ID = User ID (primary key)
UID = relationship
The key is stored with the following structure
USER_EXCHANGE:USER_ID:4030:UID:63867a4c6948e9405f4dd73bd9eaf8782b7a6667063dbd85014bd02046f6cc2e
I am trying to find all the records of the user 4030...
using (var redisClient = new RedisClient ())
{
List<object> ALL_UID = redisClient.Get<List<object>>("USER_EXCHANGE:USER_ID:4030:UID:*");
}
What am I doing wrong? Thank you all for your help.
Upvotes: 2
Views: 3936
Reputation: 2316
Hi as you're trying to fetch all keys matching a pattern you should use KEYS. GET won't match patterns. by will retrieve complete full names.
Caution this is a debug function and not a production function. doc: https://redis.io/commands/keys
Production simple solution, recommanded for you is :
This is a good practice in REDIS.
Upvotes: 1