How can I use AppFabric DataCache and get values by keys?

eg. I want to do:

string[] keys = new []{"key1","key2", ...,"keyLast" }
object[] values = factory.GetCache("MyCache").Get(keys);

This seems like a very fundamental operation, I am hoping there is a way to do this without roundtripping to the backing store.

P.s. I know redis ServiceStack implementation supports this out of the box, for my use case this is a mandatory feature in deciding which technology to adopt for my company.

有帮助吗?

解决方案

The BulkGet method (MSDN) can do this. It accepts an IEnumerable<string> of the keys and the name of a region to query (which could be the System region, which you can get with the GetSystemRegionName method), and returns an IEnumerable<KeyValue<string, object>> of the keys and values (so you know which value goes with which key). Alternatively, if you're using regions, you can use the GetObjectsInRegion method, which will return the same structure (IEnumerable<KeyValuePair<string, object>>) containing all the objects cached in that region.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top