Welcome to in-memory-database module 👋
Simple caching module that works a like memcached. All keys are stored in a single object.
Install
npm install --save in-memory-database
Usage
const { InMemoryDatabase } = require('in-memory-database');
const client = new InMemoryDatabase();
client.set('key', 'value');
client.get('key');
Docs
class InMemoryDatabase()
Class Methods
These functions are specified in the in-memory-database.
get(key: string): any
Gets a key'svalue.
client.get('key');
set(key: string, value: any): void
Sets a key to value.
client.set('key', 'value');
delete(key: string): void
Deletes a key.
client.delete('key');
mget(keys: string[]): any
Lists all of the keys that defined in the array.
const values = client.mget(['key1', 'key2']);
mset(keyValueMap: Map<string, any>): void
Sets the multiple a keys/values.
const keyValueMap: Map<string, any> = new Map();
keyValueMap.set('key1', 'value1');
keyValueMap.set('key2', {'foo': 'bar', 'baz': 1});
client.mset(keyValueMap);
keys(): string[]
Get all database keys.
const keys = client.keys();
has(key: string): boolean
Defines if we have stored specific key in database.
const isAlreadyThere = client.has('key');
flush(): void
Flush database.
client.flush();
Run tests
npm run test
Author
👤 Dimos Botsaris
Support Me
![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)
Show your support
Give a ⭐️ if this project helped you!