README
redis-hmsetex
hmsetex lua command for redis clients
DEPRECATED
Since Redis 4.0.0, hset
has become variadic, so use it instead
hmsetex redis command
Sets the value of a hash key and updates the expire date at the same time.
HMSETEX key 1 firstname walter lastname white
In the example above, key key
expires in 1 second.
Install
$ npm install --save redis-hmsetex
Usage
The easiest usecase is to use with https://github.com/luin/ioredis as follows:
const Redis = require('ioredis');
const redis = new Redis();
require('redis-hmsetex').install(redis);
Additionally, the necessary information is exported:
const Redis = require('ioredis');
const { name, lua, numberOfKeys } = require('hmsetex');
const redis = new Redis();
redis.defineCommand(name, { lua, numberOfKeys });
Then, just run like any other command:
redis.hmsetex('some_key', 1, 'firstname', 'walter', 'lastname', 'white');
setTimeout(() => redis.hgetall('somekey'), 1100); // At this point, null is returned
Tests
There are unit tests and integration tests. Needs Node 6+ to run. The integration tests require redis to be installed.
npm test:unit
npm test:integration
npm test # run both tests
License
See the LICENSE file for license rights and limitations (MIT).