
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
memory-kv-store
Advanced tools
A simple in-memory key/value store.
This simple project is intended to mock real key value stores likes Redis or file system based stores. It can also be used in local scripts to run code that assume a key value store exists.
It requires a delay services to be passed in, you can find an implementation
in the common-services
project.
Creates a key/value store
Promise.<KV>Instantiate the kv service
Creates a key/value store
Kind: global class
Promise.<void>Promise.<*>Promise.<void>Promise.<void>Promise.<Array.<*>>Promise.<void>Promise.<void>Set a value in the store
Kind: instance method of KV
Returns: Promise.<void> - A promise to be resolved when the value is stored.
| Param | Type | Description |
|---|---|---|
| key | String | The key to store the value at |
| value | * | The value to store |
| [ttl] | number | The duration in milliseconds the value remains valid |
Example
kv.set('hello', 'world');
.then(() => console.log('Stored!'));
// Prints: Stored!
Promise.<*>Get a value from the store
Kind: instance method of KV
Returns: Promise.<*> - A promise that resolve to the actual value.
| Param | Type | Description |
|---|---|---|
| key | String | The key that map to the value |
Example
kv.get('hello');
.then((value) => console.log(value));
// Prints: world
Promise.<void>Delete a value from the store
Kind: instance method of KV
Returns: Promise.<void> - A promise that resolve once the value is deleted.
| Param | Type | Description |
|---|---|---|
| key | String | The keyof the deleted value |
Example
kv.delete('hello');
.then((value) => console.log('Deleted!'));
// Prints: Deleted!
Promise.<void>Set a several values in the store
Kind: instance method of KV
Returns: Promise.<void> - A promise to be resolved when the values are stored.
| Param | Type | Description |
|---|---|---|
| keys | Array.String | The keys to store the values at |
| values | Array | The values to store |
| [ttls] | Array.number | The duration in milliseconds each values remains valid |
Example
kv.bulkSet(['hello', 'foo'], ['world', 'bar']);
.then(() => console.log('Stored!'));
// Prints: Stored!
Promise.<Array.<*>>Get a several values from the store
Kind: instance method of KV
Returns: Promise.<Array.<*>> - A promise to be resolved when the values
are retrieved.
| Param | Type | Description |
|---|---|---|
| keys | Array.String | The keys to retrieve the values |
Example
kv.bulkGet(['hello', 'foo']);
.then((values) => console.log(values));
// Prints: ['world', 'bar']
Promise.<void>Delete values for several keys from the store
Kind: instance method of KV
Returns: Promise.<void> - A promise to be resolved when the values
are deleted.
| Param | Type | Description |
|---|---|---|
| keys | Array.String | The keys for which to delete the values |
Example
kv.bulkDelete(['hello', 'foo']);
.then((values) => console.log('Deleted!'));
// Prints: Deleted!
Promise.<KV>Instantiate the kv service
Kind: global function
Returns: Promise.<KV> - A promise of the kv service
| Param | Type | Description |
|---|---|---|
| services | Object | The services to inject |
| services.delay | function | A delaying function |
| services.time | function | A timing function |
| [services.log] | function | A logging function |
| [services.KV_TTL] | Number | The store time to live |
| [services.KV_STORE] | Map | The store for values as a simple object, it is useful to get a synchronous access to the store in tests for example. |
Example
import initKV from 'memory-kv-store';
const kv = await initKV({
delay: Promise.delay.bind(Promise),
});
FAQs
A simple in-memory key/value store.
We found that memory-kv-store demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.