Skip to content
/ tempdb Public

Redis-backed ephemeral key-value store for Node

License

Notifications You must be signed in to change notification settings

shanev/tempdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TempDB

npm version Build Status codecov codebeat badge Dependencies

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

Ports to other languages

Packages

No packages published