/nestjs-redis

Redis(ioredis) module for NestJS framework

Primary LanguageTypeScriptMIT LicenseMIT

Nest Logo

Redis(ioredis) module for NestJS framework.

npm (scoped) NPM npm Vulnerabilities for npm package CodeFactor

Features 🚀

  • Support redis and cluster
  • Support health check
  • Support multiple clients
  • Inject a redis/cluster client via @InjectRedis() and @InjectCluster()
  • Get a redis/cluster client via RedisManager and ClusterManager

Documentation

legacy V2 and V3@next, click here.

legacy V3, click here.

legacy V4, click here.

Test coverage

Statements Branches Functions Lines
Statements Branches Functions Lines

Install

This package supports both nestjs 7.x and 8.x.

$ npm install --save @liaoliaots/nestjs-redis ioredis
$ npm install --save-dev @types/ioredis
$ yarn add @liaoliaots/nestjs-redis ioredis
$ yarn add --dev @types/ioredis

Distributed locks

Test a class

This package exports getRedisToken() and getClusterToken() functions that return an internal injection token based on the provided context. Using this token, you can provide a mock implementation of the redis/cluster client using any of the standard custom provider techniques, including useClass, useValue, and useFactory.

const module: TestingModule = await Test.createTestingModule({
    providers: [{ provide: getRedisToken('your namespace'), useValue: mockClient }, YourService]
}).compile();

A working example is available here.

TODO

    • COMMAND: SELECT

Author

👤 LiaoLiao

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

This project is MIT licensed.

Package dependency overview