ICacheClient
A common interface implementation that is implemented by most cache providers
Assembly: ServiceStack.Interfaces.dll
View Source
public interface ICacheClient : IDisposable
Methods
Remove(String)
Removes the specified item from the cache.
View Source
bool Remove(string key)
Returns
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. |
|
RemoveAll(IEnumerable<String>)
Removes the cache for all the keys provided.
View Source
void RemoveAll(IEnumerable<string> keys)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | keys | The keys. |
|
Get<T>(String)
Retrieves the specified item from the cache.
View Source
T Get<T>(string key)
Returns
<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. |
|
Type Parameters
T
Increment(String, UInt32)
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
long Increment(string key, uint amount)
Returns
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.
|
Decrement(String, UInt32)
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
long Decrement(string key, uint amount)
Returns
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.
|
Add<T>(String, T)
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
bool Add<T>(string key, T value)
Returns
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.
|
Type Parameters
T
Set<T>(String, T)
Sets an item into the cache at the cache key specified regardless if it already exists or not.
View Source
bool Set<T>(string key, T value)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
Type Parameters
T
Replace<T>(String, T)
Replaces the item at the cachekey specified only if an items exists at the location already.
View Source
bool Replace<T>(string key, T value)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
Type Parameters
T
Add<T>(String, T, DateTime)
View Source
bool Add<T>(string key, T value, DateTime expiresAt)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.DateTime | expiresAt |
Type Parameters
T
Set<T>(String, T, DateTime)
View Source
bool Set<T>(string key, T value, DateTime expiresAt)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.DateTime | expiresAt |
Type Parameters
T
Replace<T>(String, T, DateTime)
View Source
bool Replace<T>(string key, T value, DateTime expiresAt)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.DateTime | expiresAt |
Type Parameters
T
Add<T>(String, T, TimeSpan)
View Source
bool Add<T>(string key, T value, TimeSpan expiresIn)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.TimeSpan | expiresIn |
Type Parameters
T
Set<T>(String, T, TimeSpan)
View Source
bool Set<T>(string key, T value, TimeSpan expiresIn)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.TimeSpan | expiresIn |
Type Parameters
T
Replace<T>(String, T, TimeSpan)
View Source
bool Replace<T>(string key, T value, TimeSpan expiresIn)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | key |
<T> | value |
System.TimeSpan | expiresIn |
Type Parameters
T
FlushAll()
Invalidates all data on the cache.
View Source
void FlushAll()
GetAll<T>(IEnumerable<String>)
Retrieves multiple items from the cache. The default value of T is set for all keys that do not exist.
View Source
IDictionary<string, T> GetAll<T>(IEnumerable<string> keys)
Returns
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. |
|
Type Parameters
T
SetAll<T>(IDictionary<String, T>)
Sets multiple items to the cache.
View Source
void SetAll<T>(IDictionary<string, T> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String,<T>> | values | The values. |
|
Type Parameters
T