Class CacheableKeyValueStore
The proxy class to cache IKeyValueStore operations.
Inherited Members
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.Store.dll
Syntax
public class CacheableKeyValueStore : IKeyValueStore, IDisposable
Constructors
| Improve this Doc View SourceCacheableKeyValueStore(IKeyValueStore, Int32)
Creates a new CacheableKeyValueStore.
Declaration
public CacheableKeyValueStore(IKeyValueStore keyValueStore, int cacheSize = 100)
Parameters
Type | Name | Description |
---|---|---|
IKeyValueStore | keyValueStore | An IKeyValueStore implementation to do real operations via CacheableKeyValueStore. |
Int32 | cacheSize | The capacity of the values cache. |
Methods
| Improve this Doc View SourceDelete(in KeyBytes)
Deletes the given key. If the key does not exist, nothing happens.
Declaration
public void Delete(in KeyBytes key)
Parameters
Type | Name | Description |
---|---|---|
KeyBytes | key | A key to delete. |
Delete(IEnumerable<KeyBytes>)
Delete multiple keys
at once.
Declaration
public void Delete(IEnumerable<KeyBytes> keys)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyBytes> | keys | Keys to delete. The order of keys does not matter. Non-existent keys are ignored. |
Dispose()
The proxy class to cache IKeyValueStore operations.
Declaration
public void Dispose()
Exists(in KeyBytes)
Checks whether the given key exists in the store.
Declaration
public bool Exists(in KeyBytes key)
Parameters
Type | Name | Description |
---|---|---|
KeyBytes | key | A key to check. |
Returns
Type | Description |
---|---|
Boolean | true if the key exists; otherwise, false. |
Get(in KeyBytes)
Gets the value associated with the specified key.
Declaration
public byte[] Get(in KeyBytes key)
Parameters
Type | Name | Description |
---|---|---|
KeyBytes | key | The key whose value to get. |
Returns
Type | Description |
---|---|
Byte[] | The value associated with the specified key. |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | Thrown when the key is not found. |
ListKeys()
Lists all keys that have been stored in the storage.
Declaration
public IEnumerable<KeyBytes> ListKeys()
Returns
Type | Description |
---|---|
IEnumerable<KeyBytes> | All keys in an arbitrary order. The order might be vary for each call. |
Set(in KeyBytes, Byte[])
Sets the value to the key. If the key already exists, the value is overwritten.
Declaration
public void Set(in KeyBytes key, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
KeyBytes | key | The key of the value to set. |
Byte[] | value | The value to set. |
Set(IDictionary<KeyBytes, Byte[]>)
The proxy class to cache IKeyValueStore operations.
Declaration
public void Set(IDictionary<KeyBytes, byte[]> values)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<KeyBytes, Byte[]> | values |