2.0.1 • Published 1 year ago

@tonoid/redis v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@tonoid/redis

npm npm npm GitHub stars

Redis plugin for @tonoid/helpers

Init options

  • url: (defaults: process.env.REDIS_URL) Redis url
  • db: (defaults: process.env.REDIS_DB || '0') Redis database.
  • extendOptions: (default: {}) Extend RedisClient options
  • errorHandler: (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

1 year 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

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago