Reputation: 17373
I've a scenario where we need to request for 4 years worth of data. I've managed to hook up the enterprise library with in memory cache.
Problem is it takes ages to request for 4 years data and store locally. Alternative is to request for 1 year data and another 3 years subsequently as needed and add on local cache.
Could someone help me with how we can add data on to existing cached data and also how to update keys for the cache?
Upvotes: 0
Views: 545
Reputation: 2368
Enterprise Library doesn't and can't know how to append data to your object. To do this you will need to get the object from the cache, add the new data to the object and add the object back to the cache with the same key. The existing cached object will be replaced with the new one. It would look something like the following code.
string key = "key";
// get the existing cached data
var list = (List<object>) cacheManager.GetData(key);
// if there was no existing data, list will be null, so initialize it
if (list == null)
list = new List<object>();
// add the new data
list.Add(new object());
// add the data back to the cache
cacheManager.Add(key, list);
Upvotes: 2