Class DefaultKeyValueStore
The default built-in IKeyValueStore implementation. This stores data in the file system or in memory.
DefaultStore and DefaultKeyValueStore-backed
TrieStateStore can be instantiated from a URI with default+file:
scheme
using LoadStore(Uri), e.g.:
default+file:///var/data/planet/
default+file:///c:/Users/john/AppData/Local/planet/
The following query string parameters are supported:
journal | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s journal
parameter. |
index-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
indexCacheSize parameter. 50000 by default. |
block-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
blockCacheSize parameter. 512 by default. |
tx-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
txCacheSize parameter. 1024 by default. |
flush | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s flush
parameter. |
readonly | true or false (default). Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s readOnly
parameter. |
states-dir | Corresponds to path
parameter. It is relative to the URI path, and defaults to states . |
Inheritance
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.Store.dll
Syntax
public class DefaultKeyValueStore : object, IKeyValueStore
Constructors
| Improve this Doc View SourceDefaultKeyValueStore(Nullable<String>)
Creates a new DefaultKeyValueStore.
Declaration
public DefaultKeyValueStore(string? path)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.String> | path | The path of the directory where the storage files will be saved. If the path is null, the database is created in memory. |
Methods
| Improve this Doc View SourceDelete(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. |
Delete(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. |
Dispose()
The default built-in IKeyValueStore implementation. This stores data in the file system or in memory.
DefaultStore and DefaultKeyValueStore-backed
TrieStateStore can be instantiated from a URI with default+file:
scheme
using LoadStore(Uri), e.g.:
default+file:///var/data/planet/
default+file:///c:/Users/john/AppData/Local/planet/
The following query string parameters are supported:
journal | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s journal
parameter. |
index-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
indexCacheSize parameter. 50000 by default. |
block-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
blockCacheSize parameter. 512 by default. |
tx-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
txCacheSize parameter. 1024 by default. |
flush | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s flush
parameter. |
readonly | true or false (default). Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s readOnly
parameter. |
states-dir | Corresponds to path
parameter. It is relative to the URI path, and defaults to states . |
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 |
---|---|
System.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 |
---|---|
System.Byte[] | The value associated with the specified key. |
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(IDictionary<KeyBytes, Byte[]>)
The default built-in IKeyValueStore implementation. This stores data in the file system or in memory.
DefaultStore and DefaultKeyValueStore-backed
TrieStateStore can be instantiated from a URI with default+file:
scheme
using LoadStore(Uri), e.g.:
default+file:///var/data/planet/
default+file:///c:/Users/john/AppData/Local/planet/
The following query string parameters are supported:
journal | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s journal
parameter. |
index-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
indexCacheSize parameter. 50000 by default. |
block-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
blockCacheSize parameter. 512 by default. |
tx-cache | Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s
txCacheSize parameter. 1024 by default. |
flush | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s flush
parameter. |
readonly | true or false (default). Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Int32, Boolean, Boolean)'s readOnly
parameter. |
states-dir | Corresponds to path
parameter. It is relative to the URI path, and defaults to states . |
Declaration
public void Set(IDictionary<KeyBytes, byte[]> values)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<KeyBytes, System.Byte[]> | values |
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. |
System.Byte[] | value | The value to set. |