ICacheClientAsync
Assembly: ServiceStack.Interfaces.dll
View Source
public interface ICacheClientAsync
Methods
RemoveAsync(String, CancellationToken)
Removes the specified item from the cache.
View Source
Task<bool> RemoveAsync(string key, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
:
true if the item was successfully removed from the cache; false otherwise.
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the item to delete. |
|
| System.Threading.CancellationToken
| token | |
RemoveAllAsync(IEnumerable<String>, CancellationToken)
Removes the cache for all the keys provided.
View Source
Task RemoveAllAsync(IEnumerable<string> keys, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | keys | The keys. |
|
| System.Threading.CancellationToken
| token | |
GetAsync<T>(String, CancellationToken)
Retrieves the specified item from the cache.
View Source
Task<T> GetAsync<T>(string key, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<<T>>
:
The retrieved item, or <returns>null</returns> if the key was not found.
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the item to retrieve. |
|
| System.Threading.CancellationToken
| token | |
Type Parameters
T
IncrementAsync(String, UInt32, CancellationToken)
Increments the value of the specified key by the given amount. The operation is atomic and happens on the server. A non existent value at key starts at 0
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
View Source
Task<long> IncrementAsync(string key, uint amount, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Int64>
:
The new value of the item or -1 if not found.
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the item to increment. |
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
|
| System.UInt32
| amount | The amount by which the client wants to increase the item.
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
|
| System.Threading.CancellationToken
| token | |
DecrementAsync(String, UInt32, CancellationToken)
Increments the value of the specified key by the given amount. The operation is atomic and happens on the server. A non existent value at key starts at 0
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
View Source
Task<long> DecrementAsync(string key, uint amount, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Int64>
:
The new value of the item or -1 if not found.
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the item to increment. |
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
|
| System.UInt32
| amount | The amount by which the client wants to decrease the item.
The item must be inserted into the cache before it can be changed. The item must be inserted as a <xref href="System.String" data-throw-if-not-resolved="false"></xref>. The operation only works with <xref href="System.UInt32" data-throw-if-not-resolved="false"></xref> values, so -1 always indicates that the item was not found.
|
| System.Threading.CancellationToken
| token | |
AddAsync<T>(String, T, CancellationToken)
Adds a new item into the cache at the specified cache key only if the cache is empty.
The item does not expire unless it is removed due memory pressure.
View Source
Task<bool> AddAsync<T>(string key, T value, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
:
true if the item was successfully stored in the cache; false otherwise.
The item does not expire unless it is removed due memory pressure.
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key used to reference the item. |
The item does not expire unless it is removed due memory pressure.
|
| <T>
| value | The object to be inserted into the cache.
The item does not expire unless it is removed due memory pressure.
|
| System.Threading.CancellationToken
| token | |
Type Parameters
T
SetAsync<T>(String, T, CancellationToken)
Sets an item into the cache at the cache key specified regardless if it already exists or not.
View Source
Task<bool> SetAsync<T>(string key, T value, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.Threading.CancellationToken | token |
Type Parameters
T
ReplaceAsync<T>(String, T, CancellationToken)
Replaces the item at the cachekey specified only if an items exists at the location already.
View Source
Task<bool> ReplaceAsync<T>(string key, T value, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.Threading.CancellationToken | token |
Type Parameters
T
AddAsync<T>(String, T, DateTime, CancellationToken)
View Source
Task<bool> AddAsync<T>(string key, T value, DateTime expiresAt, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.DateTime | expiresAt |
System.Threading.CancellationToken | token |
Type Parameters
T
SetAsync<T>(String, T, DateTime, CancellationToken)
View Source
Task<bool> SetAsync<T>(string key, T value, DateTime expiresAt, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.DateTime | expiresAt |
System.Threading.CancellationToken | token |
Type Parameters
T
ReplaceAsync<T>(String, T, DateTime, CancellationToken)
View Source
Task<bool> ReplaceAsync<T>(string key, T value, DateTime expiresAt, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.DateTime | expiresAt |
System.Threading.CancellationToken | token |
Type Parameters
T
AddAsync<T>(String, T, TimeSpan, CancellationToken)
View Source
Task<bool> AddAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.TimeSpan | expiresIn |
System.Threading.CancellationToken | token |
Type Parameters
T
SetAsync<T>(String, T, TimeSpan, CancellationToken)
View Source
Task<bool> SetAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.TimeSpan | expiresIn |
System.Threading.CancellationToken | token |
Type Parameters
T
ReplaceAsync<T>(String, T, TimeSpan, CancellationToken)
View Source
Task<bool> ReplaceAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.TimeSpan | expiresIn |
System.Threading.CancellationToken | token |
Type Parameters
T
FlushAllAsync(CancellationToken)
Invalidates all data on the cache.
View Source
Task FlushAllAsync(CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Threading.CancellationToken | token |
GetAllAsync<T>(IEnumerable<String>, CancellationToken)
Retrieves multiple items from the cache. The default value of T is set for all keys that do not exist.
View Source
Task<IDictionary<string, T>> GetAllAsync<T>(IEnumerable<string> keys, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IDictionary<System.String,<T>>>
:
a Dictionary holding all items indexed by their key.
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | keys | The list of identifiers for the items to retrieve. |
|
| System.Threading.CancellationToken
| token |
|
Type Parameters
T
SetAllAsync<T>(IDictionary<String, T>, CancellationToken)
Sets multiple items to the cache.
View Source
Task SetAllAsync<T>(IDictionary<string, T> values, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Collections.Generic.IDictionary<System.String,<T>> | values |
System.Threading.CancellationToken | token |
Type Parameters
T
GetTimeToLiveAsync(String, CancellationToken)
View Source
Task<TimeSpan?> GetTimeToLiveAsync(string key, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Nullable<System.TimeSpan>>
Parameters
Type | Name |
---|---|
System.String | key |
System.Threading.CancellationToken | token |
GetKeysByPatternAsync(String, CancellationToken)
View Source
IAsyncEnumerable<string> GetKeysByPatternAsync(string pattern, CancellationToken token = default(CancellationToken))
Returns
IAsyncEnumerable<System.String>
Parameters
Type | Name |
---|---|
System.String | pattern |
System.Threading.CancellationToken | token |
RemoveExpiredEntriesAsync(CancellationToken)
View Source
Task RemoveExpiredEntriesAsync(CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
System.Threading.CancellationToken | token |