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 Local
Declaration
public LocalFileDistributedCache(IOptions<LocalFileDistributedCacheOptions> localFileDistributedCacheOptions)
Parameters
Type | Name | Description |
---|---|---|
IOptions<Local |
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. |
key | A string identifying the requested value. |
Returns
Type | Description |
---|---|
System. |
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. |
key | A string identifying the requested value. |
System. |
token | Optional. The System. |
Returns
Type | Description |
---|---|
System. |
The System. |
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. |
key | A string identifying the requested calue. |
Exceptions
Type | Condition |
---|---|
System. |
Refresh is not supported by Local |
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. |
key | A string identifying the requested value. |
System. |
token | Optional. The System. |
Returns
Type | Description |
---|---|
System. |
The System. |
Exceptions
Type | Condition |
---|---|
System. |
Refresh is not supported by Local |
Remove(String)
Removes the value with the given key.
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System. |
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. |
key | A string identifying the requested value. |
System. |
token | Optional. The System. |
Returns
Type | Description |
---|---|
System. |
The System. |
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. |
key | A string identifying the requested value. |
System. |
value | The value to set in the cache. |
Distributed |
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. |
key | A string identifying the requested value. |
System. |
value | The value to set in the cache. |
Distributed |
options | The cache options for the value. |
System. |
token | Optional. The System. |
Returns
Type | Description |
---|---|
System. |
The System. |
Exceptions
Type | Condition |
---|---|
System. |