Class MemoryCacheProvider
Implements the ICacheProvider that stores values in the local memory.
Inheritance
Inherited Members
Namespace: Nevatech.Vsb.Repository.Caching
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public sealed class MemoryCacheProvider : ICacheProvider, IDisposable
Constructors
MemoryCacheProvider()
Declaration
public MemoryCacheProvider()
Fields
CacheName
Name of the cache configuration (used in application configuration file).
Declaration
public const string CacheName = "Nevatech.Vsb.Runtime.MessageCache"
Field Value
Type | Description |
---|---|
System.String |
Methods
Delete(String)
Deletes a key from cache.
Declaration
public void Delete(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to delete. |
Dispose()
Releases internal cache.
Declaration
public void Dispose()
GetOrSet<T>(String, Func<T>, Func<T, T>, Nullable<TimeSpan>, Boolean)
Gets a value from cache. If value does not exist, it may be optionally created. If it exists, it may be optionally updated. This operation is atomic.
Declaration
public T GetOrSet<T>(string key, Func<T> createValue = null, Func<T, T> updateValue = null, TimeSpan? expiry = default(TimeSpan? ), bool updateExpiry = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The cache key at which cached string value is stored. |
System.Func<T> | createValue | A method returning a new value for caching that is invoked, if cache entry is not found. |
System.Func<T, T> | updateValue | A method returning an updated value for caching that is invoked if existing cache entry is found. |
System.Nullable<System.TimeSpan> | expiry | A timeout on key. After the timeout has expired, the key will automatically be deleted. Setting this value to null will remove the timeout (make key persistent). |
System.Boolean | updateExpiry | True to update existing key expiry to a new value (sliding expiration). The default value is false. |
Returns
Type | Description |
---|---|
T | The cached value or default(T), if cache entry was not found and was not created. |
Type Parameters
Name | Description |
---|---|
T | Type of the stored value. |