Method GetBulk
GetBulk<T>(IEnumerable<String>, ReadThruOptions)
Retrieves the objects from cache for the given keys as key-value pairs. Options regarding reading from data source (read-through) can be set.
Declaration
IDictionary<string, T> GetBulk<T>(IEnumerable<string> keys, ReadThruOptions readThruOptions = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
keys | The keys against which items are to be fetched from cache. |
Read |
readThruOptions | Read |
Returns
Type | Description |
---|---|
System. |
The retrieved cache items as key-value pairs. |
Type Parameters
Name | Description |
---|---|
T | Specifies the type of value obtained from the cache. |
Examples
The following example demonstrates how to retrieve the value cached against multiple keys with ReadThruOptions.
ICache cache = CacheManager.GetCache("demoClusteredCache");
List<string> keys = new List<string>()
{
"Product0",
"Product1",
"Product2"
};
ReadThruOptions readThruOptions = new ReadThruOptions(ReadMode.ReadThru);
IDictionary<string, Product> items = cache.GetBulk<Product>(keys, readThruOptions);
Exceptions
Type | Condition |
---|---|
System. |
Keys contain a null reference. |
System. |
Keys cannot be serialized. |