Nivas
Nivas

Reputation: 358

Getting multiple values by passing a key in redis cache

I am using Redis cache from StackExchange.Redis.

How can i retrieve set of values if a key contains the specified string.

For example,

  1. Key: "User:1" Value: "User 1 Details"
  2. Key: "User:2" Value: "User 2 Details"

I want to get list of users by passing a key value. something like sending user as key like that.

Currently my code to set key value is below,

// _redis is IRedisCacheClient from StackExchange.Redis.Extensions.Core.Abstractions

_redis.Db0.Add("user:1", user);

Any suggestions/help is welcome.

Upvotes: 2

Views: 1585

Answers (1)

Nivas
Nivas

Reputation: 358

After a bit of research for a while sharing knowledge here. The list of users can be retrieved by passing key like this "user:*"

Example,

Key: "user:1" with Value: "User1 object"

Key: "user:2" with Value: "User2 object"

The key to get list of users will be "user:*"

Upvotes: 3

Related Questions