1.0.20 • Published 5 years ago

@lucasvmiguel/kv-store v1.0.20

Weekly downloads
17
License
MIT
Repository
github
Last release
5 years ago

Version Build Status Downloads

Description

Key value store library that uses your current database. It might be the case that you don't want to spend money in a new instance or in another service.

PS: if you have money to spend, maybe it's better to use a better database solution for this particular problem, as suggested here: https://www.reddit.com/r/javascript/comments/beyjef/key_value_storage_in_your_own_database_if_you/el9s32b?utm_source=share&utm_medium=web2x

Databases available:

  • Mysql
  • Postgres (roadmap)
  • MongoDB (roadmap)

Installation

npm install --save @lucasvmiguel/kv-store

How to use

import * as kvStore from '@lucasvmiguel/kv-store';

const connection = mysql.createConnection({
    host: '...',
    user: '...',
    password: '...',
    port: '...',
    database: '...',
});

await kvStore.init({
  type: 'mysql',
  client: connection,
  tableName: 'kvstore_keyvalues', // OPTIONAL
  debug: false, // OPTIONAL
});

await kvStore.put('USER:123', 'abc');
const abc = await kvStore.get('USER:123');

// Expiration in seconds
await kvStore.putJson('USER:456', {foo: "bar"}, { expiration: 60 });
const fooBar = await kvStore.getJson('USER:456');

License

MIT

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago