C
C#2y ago
RDasher

❔ MongoDB: Cache conventions

Hello, I'm trying to figure out what's a better convention for caching records in my API application. What I currently do:
public IEnumerable<T> Table(FilterDefinition<T> _Filter) => _DBSet.Find(_Filter).ToList();
public IEnumerable<T> Table(FilterDefinition<T> _Filter) => _DBSet.Find(_Filter).ToList();
Depending on the filters I have selected (list search page, finding a specific record, etc), I send that as a filter definition into the MongoDb<T>.Find(_Filter) method. Now for the sake of caching, these filter definitions would not work if I'm correct, so I would need to first load all records into Cache, then do filtering. What's the recommended way of doing this? >Create Filter Query -> Search Db -> Get Results >Get All Results -> Create Filter Query -> Query Results
2 Replies
RDasher
RDasher2y ago
To be clear: I'm aware that the second option is the better option, I was wondering if there are other options besides these two that's perhaps outside my knowledge
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.