Last post Sep 01, 2016 06:59 PM by deepalgorithm
Aug 25, 2016 10:17 AM|sudip_inn|LINK
suppose i have populate my list<customer> from sql server and i have cache that data to redis cache. now i know how to read back but if i need to only read few based on filter then how it will be possible.
i just like to know how could i filter data from redis cache at the time of reading instead of reading whole data from redis cache ?
suppose customer name start with "S" and country is UK etc multiple clause.
if possible show me how to do it with chunk of code just for a example.
Sep 01, 2016 05:58 PM|deepalgorithm|LINK
You will need a Redis client. If you haven't picked one yet, I recommend the one from
StackExchange.Redis and review the documentation in detail.
A "cache server" such as Redis is not intended to be used as a queryable store. With Redis - you
build whatever indexes you need yourself.
To get a value:
string value = "abcdefg";
await db.StringSetAsync("mykey", value);
string value = await db.StringGetAsync("mykey");
There is also an async version:
Sep 01, 2016 06:44 PM|sudip_inn|LINK
Sep 01, 2016 06:59 PM|deepalgorithm|LINK
Its an older client.
See StackExchange.Redis section from above link.
"This .NET client was developed by Stack Exchange for very high performance needs (replacement to the earlier BookSleeve)."
Redis does not directly support what you are asking for. As I mentioned in my first answer - "A "cache server" such as Redis is not intended to be used as a queryable store".
You are limited to querying all keys at once or one or more keys specified by their exact name. This usage pattern probably means you need a hash plus another data structure to keep record of the interesting keys, or
two or more separate hashes.