{"_id":"@apitable/nestjs-redis","_rev":"5-c5faaca8e082df1071b241f46608db93","name":"@apitable/nestjs-redis","dist-tags":{"latest":"1.3.4"},"versions":{"1.3.4":{"name":"@apitable/nestjs-redis","version":"1.3.4","keywords":["nestjs","nest","redis","nestjs-redis"],"author":{"name":"skunight"},"license":"MIT","_id":"@apitable/nestjs-redis@1.3.4","maintainers":[{"name":"apitable","email":"devops@apitable.com"}],"homepage":"https://github.com/apitable/nestjs-redis#readme","bugs":{"url":"https://github.com/apitable/nestjs-redis/issues"},"dist":{"shasum":"d62da246058fa6a4538486248fa0141731a2f3c1","tarball":"https://registry.npmjs.org/@apitable/nestjs-redis/-/nestjs-redis-1.3.4.tgz","fileCount":23,"integrity":"sha512-pJpFQ9gvBrg4teGgb46uckmcXxyFD/3LVkczCR0rXQFEmGNt3wOKCj+/7pOdRJUkoURae/fJjtLKzKU99bY1cw==","signatures":[{"sig":"MEQCIDolMC/MSlRGAWE+dlSajJuL8M6EFhplx//3/ExWyC2KAiBHKJeBpAUYBAqQiVqG0BiT94bQawNswIAt5fL5Wd1/yA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjdFfLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqELQ//ZoN2Yvy0R0Y77kn5twAZfrpGX/P5bxKqWcu1FnqbG3zAUkP9\r\nyOnrMczE88bfiCxKD1SdwcG6ER1WV36OwOnsldXDdkTBpV7ZhtL/UqO/KyvM\r\nOwQLPQcZW3E1WN2J7PdJC0/LaWH3JCSbdgRIhs4Kcjd0iFMFX0+PGpeMjzU6\r\ncpp1FyjD0kcbJQmu//VU6KPvMGUsQ/ZIclHYndU9I4OzqaK1FeTDqm2YIAph\r\nvz8Hs7W8eWkjWp4IM3H2uBbnYXb9XTQWAG+/09mhTsHbbkbH+96yjyt5yymm\r\n3lZVB3hhS35zfQIPU1UrukrnQgedlluQ5sYIV94c/gts3U/2htlZmCJnYUKK\r\nUVZx6GdGEecHTgFJO11Rc+J+UwwMvslutSKOozQbnFceX1NaDzvPOY/dh+ly\r\nSy118Vqb2DmuiXLKikR7s7BaI3Lr37bWloiK1UPs+P88XTiwcPjfA/57LLrj\r\n+imXdAtmUtmM+/PH4m5xnt3ZTLFmOtEzOT+Ry1XCJJkfX/jbnzLMRrL2XDvO\r\n4yGK4M37/RyRBEmaN59QmMX29Bmy9AQLp7ssQlpNmQU3HioUYNoYKrkgT4tg\r\ns0a0w6AGLxSOZl6XH+VwwiJr1twe5QZH9PPsp6m4aQ3QWou3Yq9Txy+G20RP\r\nmvt8idIPTkEDju9g3pqBbivTszS3SLOhkqI=\r\n=jjQR\r\n-----END PGP SIGNATURE-----\r\n"},"types":"./index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"c951349c4052f138520fc1fdd971e45f01e2c19e","scripts":{"lint":"eslint -c .eslintrc.js","test":"jest --passWithNoTests","build":"rimraf dist && tsc -p tsconfig.json","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","precommit":"lint-staged","prepublish":"yarn run build","test:watch":"jest --watch","publish-public":"yarn publish --access public"},"_npmUser":{"name":"apitable","email":"devops@apitable.com"},"repository":{"url":"git+https://github.com/apitable/nestjs-redis.git","type":"git"},"_npmVersion":"8.5.5","description":"a NestJS ioRedis module","directories":{},"_nodeVersion":"16.15.0","dependencies":{"rxjs":"^6","uuid":"^8","ioredis":"^4","@types/uuid":"*","@nestjs/core":"^7.4.4","@nestjs/common":"^7.4.4","@types/ioredis":"*","reflect-metadata":"*"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26","eslint":"*","rimraf":"*","ts-jest":"^26","prettier":"^2","typescript":"^4","@types/node":"*","@nestjs/testing":"^7","eslint-plugin-jest":"^24","eslint-config-prettier":"^6","eslint-plugin-prettier":"^3","@typescript-eslint/parser":"^4","cz-conventional-changelog":"^3","@typescript-eslint/eslint-plugin":"^4"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-redis_1.3.4_1668569035161_0.6492175416004433","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-11-16T03:23:55.114Z","modified":"2025-07-01T12:12:36.460Z","1.3.4":"2022-11-16T03:23:55.325Z"},"bugs":{"url":"https://github.com/apitable/nestjs-redis/issues"},"author":{"name":"skunight"},"license":"MIT","homepage":"https://github.com/apitable/nestjs-redis#readme","keywords":["nestjs","nest","redis","nestjs-redis"],"repository":{"url":"git+https://github.com/apitable/nestjs-redis.git","type":"git"},"description":"a NestJS ioRedis module","maintainers":[{"email":"wangkailang@vikadata.com","name":"vika-apitable"},{"email":"wangkailang992@gmail.com","name":"wangkailang992"},{"email":"devops@apitable.com","name":"apitableinc"},{"email":"karma.pan@gmail.com","name":"ifidea"}],"readme":"\n# Nestjs Redis\n\n<div>\n  <a href=\"https://www.npmjs.com/package/nestjs-redis\">\n    <img src=\"https://img.shields.io/npm/v/nestjs-redis.svg\" alt=\"npm version\">\n  </a>\n  <a href=\"https://www.npmjs.com/package/nestjs-redis\">\n    <img src=\"https://img.shields.io/npm/dw/nestjs-redis.svg\" alt=\"npm downloads\" />\n  </a>\n</div>\n\nRedis component for NestJs.\n\n\n### Installation\n\n**Yarn**\n```bash\nyarn add nestjs-redis\n```\n\n**NPM**\n```bash\nnpm install nestjs-redis --save\n```\n\n### Getting Started\nLet's register the RedisModule in `app.module.ts`\n\n```typescript\nimport { Module } from '@nestjs/common'\nimport { RedisModule} from 'nestjs-redis'\n\n@Module({\n    imports: [\n        RedisModule.register(options)\n    ],\n})\nexport class AppModule {}\n```\nWith Async\n```typescript\nimport { Module } from '@nestjs/common';\nimport { RedisModule} from 'nestjs-redis'\n\n@Module({\n    imports: [\n        RedisModule.forRootAsync({\n            useFactory: (configService: ConfigService) => configService.get('redis'),         // or use async method\n            //useFactory: async (configService: ConfigService) => configService.get('redis'),\n            inject:[ConfigService]\n        }),\n    ],\n})\nexport class AppModule {}\n```\nAnd the config file look like this\nWith single client\n```typescript\nexport default {\n    host: process.env.REDIS_HOST,\n    port: parseInt(process.env.REDIS_PORT),\n    db: parseInt(process.env.REDIS_DB),\n    password: process.env.REDIS_PASSWORD,\n    keyPrefix: process.env.REDIS_PRIFIX,\n}\nOr\nexport default {\n    url: 'redis://:authpassword@127.0.0.1:6380/4',\n}\n```\nWith custom error handler\n```typescript\nexport default {\n    url: 'redis://:authpassword@127.0.0.1:6380/4',\n    onClientReady: (client) => {\n      client.on('error', (err) => {}\n    )},\n}\n```\nWith multi client\n```typescript\nexport default [\n    {\n        name:'test1',\n        url: 'redis://:authpassword@127.0.0.1:6380/4',\n    },\n    {\n        name:'test2',\n        host: process.env.REDIS_HOST,\n        port: parseInt(process.env.REDIS_PORT),\n        db: parseInt(process.env.REDIS_DB),\n        password: process.env.REDIS_PASSWORD,\n        keyPrefix: process.env.REDIS_PRIFIX,\n    },\n]\n```\nAnd use in your service\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { RedisService } from 'nestjs-redis';\n\n@Injectable()\nexport class TestService {\n  constructor(\n    private readonly redisService: RedisService,\n  ) { }\n  async root(): Promise<boolean> {\n    const client = await this.redisService.getClient('test')\n    return true\n  }\n}\n```\nOptions\n```typescript\ninterface RedisOptions {\n    /**\n     * client name. default is a uuid, unique.\n     */\n    name?: string;\n    url?: string;\n    port?: number;\n    host?: string;\n    /**\n     * 4 (IPv4) or 6 (IPv6), Defaults to 4.\n     */\n    family?: number;\n    /**\n     * Local domain socket path. If set the port, host and family will be ignored.\n     */\n    path?: string;\n    /**\n     * TCP KeepAlive on the socket with a X ms delay before start. Set to a non-number value to disable keepAlive.\n     */\n    keepAlive?: number;\n    connectionName?: string;\n    /**\n     * If set, client will send AUTH command with the value of this option when connected.\n     */\n    password?: string;\n    /**\n     * Database index to use.\n     */\n    db?: number;\n    /**\n     * When a connection is established to the Redis server, the server might still be loading\n     * the database from disk. While loading, the server not respond to any commands.\n     * To work around this, when this option is true, ioredis will check the status of the Redis server,\n     * and when the Redis server is able to process commands, a ready event will be emitted.\n     */\n    enableReadyCheck?: boolean;\n    keyPrefix?: string;\n    /**\n     * When the return value isn't a number, ioredis will stop trying to reconnect.\n     * Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858\n     */\n    retryStrategy?(times: number): number | false;\n    /**\n     * By default, all pending commands will be flushed with an error every\n     * 20 retry attempts. That makes sure commands won't wait forever when\n     * the connection is down. You can change this behavior by setting\n     * `maxRetriesPerRequest`.\n     *\n     * Set maxRetriesPerRequest to `null` to disable this behavior, and\n     * every command will wait forever until the connection is alive again\n     * (which is the default behavior before ioredis v4).\n     */\n    maxRetriesPerRequest?: number | null;\n    /**\n     * 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore\n     * the error and do nothing.\n     */\n    reconnectOnError?(error: Error): boolean | 1 | 2;\n    /**\n     * By default, if there is no active connection to the Redis server, commands are added to a queue\n     * and are executed once the connection is \"ready\" (when enableReadyCheck is true, \"ready\" means\n     * the Redis server has loaded the database from disk, otherwise means the connection to the Redis\n     * server has been established). If this option is false, when execute the command when the connection\n     * isn't ready, an error will be returned.\n     */\n    enableOfflineQueue?: boolean;\n    /**\n     * The milliseconds before a timeout occurs during the initial connection to the Redis server.\n     * default: 10000.\n     */\n    connectTimeout?: number;\n    /**\n     * After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels.\n     * default: true.\n     */\n    autoResubscribe?: boolean;\n    /**\n     * If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected.\n     * default: true.\n     */\n    autoResendUnfulfilledCommands?: boolean;\n    lazyConnect?: boolean;\n    tls?: tls.ConnectionOptions;\n    sentinels?: Array<{ host: string; port: number; }>;\n    name?: string;\n    /**\n     * Enable READONLY mode for the connection. Only available for cluster mode.\n     * default: false.\n     */\n    readOnly?: boolean;\n    /**\n     * If you are using the hiredis parser, it's highly recommended to enable this option.\n     * Create another instance with dropBufferSupport disabled for other commands that you want to return binary instead of string\n     */\n    dropBufferSupport?: boolean;\n    /**\n     * Whether to show a friendly error stack. Will decrease the performance significantly.\n     */\n    showFriendlyErrorStack?: boolean;\n}\n```\nThat's it!\n","readmeFilename":"README.md"}