Interface ICacheHelper
Interface that describes a cache helper
Namespace: ImageVault.Common.Data.Caching
Assembly: ImageVault.Common.dll
Syntax
public interface ICacheHelper
Methods
AddOrUpdate<T>(String, T)
Adds or updates a cached item
Declaration
void AddOrUpdate<T>(string name, T value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the item to add or update |
T | value | The value to update the objectCache with |
Type Parameters
Name | Description |
---|---|
T | The type of object to add or update |
AddOrUpdate<T>(String, TimeSpan, DateTime, T)
Adds or updates a cached item
Declaration
void AddOrUpdate<T>(string name, TimeSpan slidingExpiration, DateTime absoluteExpiration, T value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the item to add or update |
System.TimeSpan | slidingExpiration | The length of time the item is valid from last reference. NoSlidingExpiration disables sliding expiration. |
System.DateTime | absoluteExpiration | The time when the cached item expires. NoAbsoluteExpiration disables absolute expiration. |
T | value | The value to update the objectCache with |
Type Parameters
Name | Description |
---|---|
T | The type of object to add or update |
Clear()
Clears all items cached using the CacheHelper for this type
Declaration
void Clear()
Get(String)
Gets an item from the objectCache
Declaration
object Get(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the item to get |
Returns
Type | Description |
---|---|
System.Object | The found item or null if no item was found |
GetOrCreate<T>(String, Func<T, TimeSpan>, Func<T, DateTime>, Func<T>)
This provides a threadsafe way to get a value from in-or-out-of-process objectCache or if the cached entry is missing, create it.
Declaration
T GetOrCreate<T>(string name, Func<T, TimeSpan> slidingExpirationFunc, Func<T, DateTime> absoluteExpirationFunc, Func<T> createAction)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the item to get |
System.Func<T, System.TimeSpan> | slidingExpirationFunc | The length of time the item is valid from last reference. NoSlidingExpiration disables sliding expiration. |
System.Func<T, System.DateTime> | absoluteExpirationFunc | The time when the cached item expires. NoAbsoluteExpiration disables absolute expiration. |
System.Func<T> | createAction | The System.Func<> to call if the value is not present that will create the value to enter in the objectCache |
Returns
Type | Description |
---|---|
T | The retrieved or created value |
Type Parameters
Name | Description |
---|---|
T | The type of object to get |
GetOrCreate<T>(String, TimeSpan, DateTime, Func<T>)
This provides a threadsafe way to get a value from in-or-out-of-process objectCache or if the cached entry is missing, create it.
Declaration
T GetOrCreate<T>(string name, TimeSpan slidingExpiration, DateTime absoluteExpiration, Func<T> createAction)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the item to get |
System.TimeSpan | slidingExpiration | The length of time the item is valid from last reference. NoSlidingExpiration disables sliding expiration. |
System.DateTime | absoluteExpiration | The time when the cached item expires. NoAbsoluteExpiration disables absolute expiration. |
System.Func<T> | createAction | The System.Func<> to call if the value is not present that will create the value to enter in the objectCache |
Returns
Type | Description |
---|---|
T | The retrieved or created value |
Type Parameters
Name | Description |
---|---|
T | The type of object to get |
Remove(String)
Removes an item from the objectCache
Declaration
void Remove(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
RemoveStartsWith(String)
Removes items from the objectCache whos names starts with the given prefix
Declaration
void RemoveStartsWith(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value |
TryGet(String, out Object)
Tries to get an item from the object cache
Declaration
bool TryGet(string name, out object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the item to get |
System.Object | value | The found item or null if no item was found |
Returns
Type | Description |
---|---|
System.Boolean | True if the operation was successful, false if operation generated an error. |
TryGetOrCreate<T>(String, TimeSpan, DateTime, Func<T>, out T)
This provides a threadsafe way to get a value from in-or-out-of-process cache or if the cached entry is missing, create it.
Declaration
bool TryGetOrCreate<T>(string name, TimeSpan slidingExpiration, DateTime absoluteExpiration, Func<T> createAction, out T value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the item to get |
System.TimeSpan | slidingExpiration | The length of time the item is valid from last reference. NoSlidingExpiration disables sliding expiration. |
System.DateTime | absoluteExpiration | The time when the cached item expires. NoAbsoluteExpiration disables absolute expiration. |
System.Func<T> | createAction | The System.Func<> to call if the value is not present that will create the value to enter in the cache |
T | value | The retrieved or created value |
Returns
Type | Description |
---|---|
System.Boolean | True if operation succeeded, false otherwize |
Type Parameters
Name | Description |
---|---|
T | The type of object to get/set |