How to Retrieve Json List Filtered in Redis?

57 views Asked by At

Let's say I have a Redis Model as follows:

 public class ExampleModel
 {
     public Guid Id { get; set; }

     public ExampleEnum? Example { get; set; }
     public Example2Enum Example2 { get; set; }

     public string Description { get; set; }
 }

I store Example Model as Json List in Redis:

var json = _redis.JSON();

await json.SetAsync("example:1", "$", exampleList);

Now I need to retrieve a list of examples based on ExampleEnum and Example2Enum

SQL alternative would be:

SELECT * FROM examples WHERE ExampleEnum = 1 AND Eample2Enum = 2;

So far everybody suggests storing examples one by one, do some Indexing, and then search by them. But I don't really need that. I want to store examples in a list in one Key/Value in Redis. And I want to perform filtered request.

Also I need to perform OFFSET FETCH logic, (SKIP, TAKE in Ef Core).

.Skip(10).Take(10).ToListAsync()

How do I do this?

My stack is: .Net 8, NRedisStack

0

There are 0 answers