Class LocalFileDistributedCache
Represents a distributed cache of serialized values that reads/writes from/to a local file.
Inheritance
Namespace: Copper.Conventions.Method.Common.V1
Assembly: Copper.Conventions.Method.Common.dll
Syntax
public class LocalFileDistributedCache : IDistributedCache
Constructors
View SourceLocalFileDistributedCache(IOptions<LocalFileDistributedCacheOptions>)
Initializes a new instance of the LocalFileDistributedCache class.
Declaration
public LocalFileDistributedCache(IOptions<LocalFileDistributedCacheOptions> localFileDistributedCacheOptions)
Parameters
Type | Name | Description |
---|---|---|
IOptions<LocalFileDistributedCacheOptions> | localFileDistributedCacheOptions | The local file distributed cache options. |
Methods
View SourceGet(String)
Gets a value with the given key.
Declaration
public byte[] Get(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
Returns
Type | Description |
---|---|
System.Byte[] | The located value or null. |
GetAsync(String, CancellationToken)
Gets a value with the given key.
Declaration
public Task<byte[]> GetAsync(string key, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
System.Threading.CancellationToken | token | Optional. The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Byte[]> | The System.Threading.Tasks.Task that represents the asynchronous operation, containing the located value or null. |
Refresh(String)
Refreshes a value in the cache based on its key, resetting its sliding expiration timeout (if any).
Declaration
public void Refresh(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested calue. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Refresh is not supported by LocalFileDistributedCache. |
RefreshAsync(String, CancellationToken)
Refreshes a value in the cache based on its key, resetting its sliding expiration timeout (if any).
Declaration
public Task RefreshAsync(string key, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
System.Threading.CancellationToken | token | Optional. The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Refresh is not supported by LocalFileDistributedCache. |
Remove(String)
Removes the value with the given key.
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
RemoveAsync(String, CancellationToken)
Removes the value with the given key.
Declaration
public Task RemoveAsync(string key, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
System.Threading.CancellationToken | token | Optional. The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
Set(String, Byte[], DistributedCacheEntryOptions)
Sets a value with the given key.
Declaration
public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
System.Byte[] | value | The value to set in the cache. |
DistributedCacheEntryOptions | options | The cache options for the value. |
SetAsync(String, Byte[], DistributedCacheEntryOptions, CancellationToken)
Sets the value with the given key.
Declaration
public Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | key | A string identifying the requested value. |
System.Byte[] | value | The value to set in the cache. |
DistributedCacheEntryOptions | options | The cache options for the value. |
System.Threading.CancellationToken | token | Optional. The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The System.Threading.Tasks.Task that represents the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException |