Interface IDataStoreService
This service is meant to act as a simple key/value store.
dataStoreService.Set("foo", "bar");
dataStoreService.Get("foo") = "bar"
dataStoreService.Get("foo", "default") = "bar"
dataStoreService.Get("invalid", "default") = "default"
Inherited Members
Namespace: IdleKit.Core
Assembly: cs.temp.dll.dll
Syntax
public interface IDataStoreService : IService, IInjectable
Methods
Clear()
Clears all cached key/value pairs.
Declaration
void Clear()
Get<TValue>(String, TValue)
Returns the value for a key. If that key doesn't exist, returns a default value.
Declaration
TValue Get<TValue>(string key, TValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to look up the value for. |
TValue | defaultValue | The default value for this key. |
Returns
Type | Description |
---|---|
TValue |
Type Parameters
Name | Description |
---|---|
TValue | The Type of the value. |
Get<TValue>(String, Func<TValue>)
Returns the value for a key. If that key doesn't exist, calls a method to retrieve the default value.
Declaration
TValue Get<TValue>(string key, Func<TValue> defaultValueSelector)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to look up the value for. |
Func<TValue> | defaultValueSelector | The method to use to generate a default value. |
Returns
Type | Description |
---|---|
TValue |
Type Parameters
Name | Description |
---|---|
TValue | The Type of the value. |
Set<TValue>(String, TValue)
Set the value for a key.
Declaration
void Set<TValue>(string key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to cache the value under. |
TValue | value | The value to cache. |
Type Parameters
Name | Description |
---|---|
TValue | The Type of the value. |
Unset(String)
Clears the cached value for a key.
Declaration
void Unset(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to clear. |