Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

Redis-backed ephemeral key-value store for Node

Topics

Resources

License

Packages

No packages published