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.
npm install tempdb
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
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');
npm install
npm test