2.0.1 • Published 2 years ago
@tonoid/redis v2.0.1
@tonoid/redis
Redis plugin for @tonoid/helpers
Init options
url: (defaults:process.env.REDIS_URL) Redis urldb: (defaults:process.env.REDIS_DB || '0') Redis database.extendOptions: (default:{}) Extend RedisClient optionserrorHandler: (default:(err) => {}) Handle redis connect eror
Exported context attributes
.redisCache: Redis cacheManager instance.getValue(key): Get a value from redis cache.setValue(key, value, ttl): Set a value in redis cache (ttl in seconds).delValue(key): Delete a value in redis cache.expire(key, value): Expire a value in redis cache (value in seconds).incr(key): Increment a value in redis cache.decr(key): Decrement a value in redis cache
Usage example
const { context, init } = require('@tonoid/helpers');
const redis = require('@tonoid/redis');
(async () => {
await init([
redis({
url: 'redis://localhost:6379',
db: 0,
errorHAndler: (err) => console.error(err)
}),
]);
await context.redis.setValue('foo', 'bar', 60); // 1min ttl
const fooValue = await context.redis.getValue('foo');
console.log(fooValue);
})();Credits
This module is maintained by Simo Elalj @tonoid
2.0.1
2 years ago
1.2.0
2 years ago
1.0.0
2 years ago
2.0.0-beta1
2 years ago
2.0.0-beta2
2 years ago
1.3.0
2 years ago
0.3.0
2 years ago
2.0.0
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.2.2
2 years ago
0.1.5
3 years ago
0.1.0
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.0.3
4 years ago
0.0.4
4 years ago
0.0.2
5 years ago
0.0.1
5 years ago