- This is still alpha stage.
- The Sync methods, if using the multiprocess flag, can hold up the thread for many seconds while trying to acquire a lock.
Simple key-value store with file persistence and optional async write queue.
Kind: global class
Initializes the store.
Param | Type | Description |
---|---|---|
[options] | object |
Path to JSON file for storage. |
Retrieves the value associated with the provided key.
Kind: instance method of Store
Returns: *
- The value associated with the key, or undefined if the key doesn't exist.
Param | Type | Description |
---|---|---|
key | string |
The key to search for. |
Asynchronously sets the value for a given key.
Kind: instance method of Store
Throws:
Error
If the value is not a primitive type.
Param | Type | Description |
---|---|---|
key | string |
The key to set. |
value | * |
The value to set. Must be a primitive type (string, number, or boolean). |
Synchronously sets the value for a given key.
Kind: instance method of Store
Throws:
Error
If the value is not a primitive type.
Param | Type | Description |
---|---|---|
key | string |
The key to set. |
value | * |
The value to set. Must be a primitive type (string, number, or boolean). |
Asynchronously removes a key and its associated value from the store.
Kind: instance method of Store
Throws:
Error
If the key doesn't exist in the store.
Param | Type | Description |
---|---|---|
key | string |
The key to remove. |
Synchronously removes a key and its associated value from the store.
Kind: instance method of Store
Throws:
Error
If the key doesn't exist in the store.
Param | Type | Description |
---|---|---|
key | string |
The key to remove. |
Clears all key-value pairs from the store.
Kind: instance method of Store
Subscribes a listener function to changes in the store. The listener is called whenever a key's value changes.
Kind: instance method of Store
Param | Type | Description |
---|---|---|
listener | function |
The function to call when a change occurs. |
Unsubscribes a listener from the change feed.
Kind: instance method of Store
Returns: boolean
- Returns true if the listener was found and removed, otherwise false.
Param | Type | Description |
---|---|---|
listener | function |
The listener to unsubscribe. |
Retrieves all key-value pairs currently in the store.
Kind: instance method of Store
Returns: Object
- An object containing all key-value pairs.