tempdb
v0.4.0
Published
Key-value store for temporary items
Downloads
5
Readme
TempDB
TempDB is Redis-backed temporary key-value store for Node. It's useful for storing temporary data such as login codes, authentication tokens, and temporary passwords.
Installation
npm install tempdb
Run Redis server
Check out Redis quickstart to install for your platform, or use one of the many cloud providers. Depending on your Redis provider, you may need to enable keyspace events for ephemeral keys to work.
A convenience script is provided for macOS default Homebrew Redis installs:
npm run redis
Usage
Require TempDB:
const TempDB = require('tempdb');
Initialize TempDB, connecting to a Redis client:
const tempDB = new TempDB(redisClient);
Add a key/value pair. Value is anything that can be serialized to JSON. Expires (in seconds) is optional.
tempDB.add('key', value, expires);
Find by key:
const value = await tempDB.find('key');
Find and delete by key:
const value = await tempDB.findAndDelete('key');
Tests
npm install
npm test