Search code examples
azure-cachingazure-redis-cache

Azure Redis Cache Batch Operations / Multiple Operations


Given a list of Keys, I want to pull out multiple values from Azure Redis Cache. How do we perform multiple operations at the same time with Azure Redis Cache?

Our data is a int/ComplexObject pair. Our data is located in SQL Server. We currently get the list by converting our List<int> of keys into a XElement object and passing that into a stored procedure - but our key size is quite small (3000 keys) - so the same data is being accessed again and again by multiple users.

It would be great if we can just cache the 3000 key/value pairs once - and then access them with something like: cache.GetValues(List<int> keys)


Solution

  • There is nothing special for Azure Redis cache. You would want to do the transaction operation supported in Redis as shown here http://redis.io/topics/transactions If you using Stack Exchange Redis client then you can refer to this page https://github.com/StackExchange/StackExchange.Redis/blob/master/Docs/Transactions.md