1.0.6 • Published 3 years ago

map-expires v1.0.6

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 years ago

Mapex

Set the value and expiration of a key for the Map by using Redis syntax.

Installation

npm install map-expires

Usage

Set key to hold value and set key to timeout after a given number of seconds. You can retrieve TTL of the given key by using ttl(key) method.

Example

const Mapex = require('map-expires');
const map = new Mapex();

map.setex('ONE', 5, 'ARG1');

setTimeout(() => {
  console.log('GET ',map.get('ONE')); // GET  ARG1
  console.log('TTL ', map.ttl('ONE')); // TTL  3
}, 2100)

setTimeout(() => {
  console.log('GET ', map.get('ONE')); // GET  ARG1
  console.log('TTL ', map.ttl('ONE')); // TTL  2
}, 3300)

setTimeout(() => {
  console.log('GET ', map.get('ONE')); // GET  ARG1
  console.log('TTL ', map.ttl('ONE')); // TTL  1
}, 4400)

setTimeout(() => {
  console.log('GET ', map.get('ONE')); // GET  undefined
  console.log('TTL ', map.ttl('ONE')); // TTL  -1
}, 5000)

History

version 1.0.6

License

GPLv3 or later

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago