5.0.0 • Published 16 days ago

redis-hsetex v5.0.0

Weekly downloads
20
License
MIT
Repository
github
Last release
16 days ago

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

5.0.0

16 days ago

4.0.1

1 year ago

4.0.0

2 years ago

3.0.0

3 years ago

2.0.0

4 years ago

1.0.1

8 years ago

1.0.0

8 years ago