Method UpdateAttributes
UpdateAttributes(String, CacheItemAttributes)
Update Cache
Declaration
bool UpdateAttributes(string key, CacheItemAttributes attributes)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | Unique key to identify the cache item. |
Cache |
attributes | An instance ofCache |
Returns
Type | Description |
---|---|
System. |
Flag that determines status of the Update operation. True if attributes of the item in cache was updated successfully and False if operation failed. |
Examples
Example demonstrates how to update Absolute Expiration of 5 minutes on an existing item in cache.
ICache cache = CacheManager.GetCache("myCache");
Product product = new Product();
product.Id = 1;
product.Name = "Chai";
string key = "Product0";
cache.Insert(key, product);
CacheItemAttributes attributes = new CacheItemAttributes();
attributes.AbsoluteExpiration = DateTime.Now.AddMinutes(5);
if(cache.UpdateAttributes(key, attributes))
{
...
}