tempdb

0.4.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i tempdb

Weekly Downloads

0

Version

0.4.0

License

MIT

Last publish

Collaborators

  • shanev