We're implementing StackExchange.Redis for storing all information regarding three e-commerce sites (aproximately 18,500 products). The information is stored in a SQL Server database, mapped to custom objects and then added in an Azure Redis Cache using this key naming convention:
urn:products:{0}:{1}
(where 0 is the store identifier and 1 is the product identifier). I read Where are KEYS, SCAN, FLUSHDB etc? and was able to get keys matching the urn:products:{0} by pattern. The issue that we´re facing is that our project involves a lot of GetAllProducts List < Products >, GetAllCategories List < Categories > and then used by LINQ functions.
Based on this:
- I tried storing all products (list of custom objects) in one key (
urn:products:all), but that approach generated timeouts in Azure Redis Cache. Is this method the suggested one? Or is it preferable to store each product in separate keys? - I don't think that is correct to loop each of the keys to get each value. Is it possible to get a collection of keys/values by pattern?
- I also read HASHES, however I don't think that they help in our requirement.