redis-hsetex

5.0.0 • Public • Published

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).

Readme

Keywords

Package Sidebar

Install

npm i redis-hsetex

Weekly Downloads

2

Version

5.0.0

License

MIT

Unpacked Size

4.39 kB

Total Files

4

Last publish

Collaborators

  • perrin4869
  • 20lives