{"_id":"@aashutoshrathi/nestjs-redis","_rev":"1-10d47cdad4280d1bb6e15f44041b792e","name":"@aashutoshrathi/nestjs-redis","dist-tags":{"latest":"1.3.3"},"versions":{"1.3.3":{"name":"@aashutoshrathi/nestjs-redis","version":"1.3.3","description":"a NestJS ioRedis module","author":{"name":"skunight"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aashutoshrathi/nestjs-redis.git"},"scripts":{"build":"rimraf dist && tsc -p tsconfig.json","precommit":"lint-staged","prepublish":"yarn run build","publish-public":"yarn publish --access public","test":"jest","test:watch":"jest --watch","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","lint":"eslint -c .eslintrc.js"},"dependencies":{"@nestjs/common":"^7.4.4","@nestjs/core":"^7.4.4","@types/ioredis":"*","@types/uuid":"*","ioredis":"^4","reflect-metadata":"*","rxjs":"^6","uuid":"^8"},"devDependencies":{"@nestjs/testing":"^7","@types/node":"*","@typescript-eslint/eslint-plugin":"^4","@typescript-eslint/parser":"^4","cz-conventional-changelog":"^3","eslint":"*","eslint-config-prettier":"^6","eslint-plugin-jest":"^24","eslint-plugin-prettier":"^3","jest":"^26","prettier":"^2","rimraf":"*","ts-jest":"^26","typescript":"^4"},"keywords":["nestjs","nest","redis","nestjs-redis"],"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"2f78c6de452be0961c24c3a95462a96b706dd54c","bugs":{"url":"https://github.com/aashutoshrathi/nestjs-redis/issues"},"homepage":"https://github.com/aashutoshrathi/nestjs-redis#readme","_id":"@aashutoshrathi/nestjs-redis@1.3.3","_nodeVersion":"10.19.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-ZEDzuNQXAovji3dWMBQTQbwmZUmaBVEBQaxdm94x8m8zOznlbsqvLS+J0ecfvsL27klpTqnWwTzslNTlFpZPpQ==","shasum":"a4df17f6d82ee2e248cce87569063fe468fe5eda","tarball":"https://registry.npmjs.org/@aashutoshrathi/nestjs-redis/-/nestjs-redis-1.3.3.tgz","fileCount":22,"unpackedSize":24837,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbYzmCRA9TVsSAnZWagAAj40P+wUmAldQjNJWNPBHMviS\ncZHB/uancfkynZyEbOB/Op4rjvfBvZDhHKcu4Yd73RTgHY/YeowO12OlGH3N\n+Umeu2SThyxuaqeAY1+qe8zH4/Dbnw0pe0EsivReToGAIkKR7GJ6ZZernLKE\nLh/5f309w0vKTIAHfW7yepuYp27B/MVyYFT5UL5yKM0swTcSuK6e39RGL3Jt\n8Z+8VqaaIQe30gcYIGZp15XyH8893oCYSDfKJ+l1C+34vr97LMievGhLq6df\nOFSbOSovyLElxKO1tjalxkJ2sMeX+CINWAXW8PUVFiF3Xh1q6rqgIaHheHSV\njZkNjwsFuI5W+8zSegGLbUCCJgHE0KTXCIhNdTNa6z5cdo5Y6sLjFub0KQ3G\nLMfYPGQBM+KbxUUYvht8xD6MH3QuR3Z/p9jMI482mLMzK6/L7a8ulJQq8DEs\n0yDuybbTPbLfS1nBizonqUkWZ8iPWmOhbQWWDM/FtdcJf46TpoF/JvBLDOSr\nqxYmhogtKhaticSUFWO4khvsy0KkwmBdkhsNVYH338BsOaR1GDPGZ32W1AOL\nyKoDXKQjrkMAN7uQJ2qkKjfCodztPUMHubKb0H+WfOSauMBxBYU+I+dAFq/A\nu+NBWB5VT+mhJlpK3Ebsdq5t0CnkpyT50OHgCWGnuki3Q/ooC/YIv8C2inB5\n0Sw0\r\n=PsXX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICOUEM2bAUmNcdS+Ur3wsyUDcvg7Oepd3DDsqX01dgifAiEAx7rJ14+b/axGGXLNzifaeN59kSnJ6bceXlgPJFCLmI0="}]},"_npmUser":{"name":"aashutoshrathi","email":"aashutoshrathi@gmail.com"},"directories":{},"maintainers":[{"name":"aashutoshrathi","email":"aashutoshrathi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-redis_1.3.3_1617792230522_0.21801291669303513"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-07T10:43:50.421Z","1.3.3":"2021-04-07T10:43:50.651Z","modified":"2022-04-04T10:55:55.145Z"},"maintainers":[{"name":"aashutoshrathi","email":"aashutoshrathi@gmail.com"}],"description":"a NestJS ioRedis module","homepage":"https://github.com/aashutoshrathi/nestjs-redis#readme","keywords":["nestjs","nest","redis","nestjs-redis"],"repository":{"type":"git","url":"git+https://github.com/aashutoshrathi/nestjs-redis.git"},"author":{"name":"skunight"},"bugs":{"url":"https://github.com/aashutoshrathi/nestjs-redis/issues"},"license":"MIT","readme":"\n# Nestjs Redis\n\nThis is fork of https://github.com/skunight/nestjs-redis with Sentinel fixes.\n\nRedis component for NestJs.\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        clientName:'test1',\n        url: 'redis://:authpassword@127.0.0.1:6380/4',\n    },\n    {\n        clientName:'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    clientName?: 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"}