Skip to content

dotcore64/redis-hsetex

Repository files navigation

redis-hsetex

Build Status npm package

hsetex lua command for redis clients

hsetex redis command

Sets the value of a hash key and updates the expire date at the same time.

HSETEX key 1 firstname walter lastname white

In the example above, key key expires in 1 second.

Install

$ npm install --save redis-hsetex

Usage

The easiest usecase is to use with https://github.com/luin/ioredis as follows:

const Redis = require('ioredis');
const hsetex = require('redis-hsetex');
const redis = new Redis();
redis.defineCommand(hsetex.name, {
  lua: hsetex.lua,
  numberOfKeys: hsetex.numberOfKeys,
})

Then, just run like any other command:

redis.hsetex('heisenberg', 1, 'firstname', 'walter');
redis.hsetex('heisenberg', 1, 'lastname', 'white');
redis.hsetex('saul_goodman', 1, 'firstname', 'jimmy', 'lastname', 'mcgill');
setTimeout(() => redis.hgetall('heisenberg'), 1100); // At this point, null is returned

Tests

There are unit tests and integration tests.

docker-compose up
npm test:unit
npm test:integration
npm test # run both tests

License

See the LICENSE file for license rights and limitations (MIT).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •