{"_id":"@42how/nestjs-redis","_rev":"2-c9284bd56b7c3ef9b0b74b644af9c7cf","name":"@42how/nestjs-redis","dist-tags":{"latest":"1.3.5"},"versions":{"1.3.4":{"name":"@42how/nestjs-redis","version":"1.3.4","description":"a NestJS ioRedis module","author":{"name":"skunight"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/skunight/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"}},"types":"./index.d.ts","gitHead":"0b1f99ac8ec0c7f2ae64f8cd30b32b7ad324cfaf","bugs":{"url":"https://github.com/skunight/nestjs-redis/issues"},"homepage":"https://github.com/skunight/nestjs-redis#readme","_id":"@42how/nestjs-redis@1.3.4","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-siwOj9RUELY33xTREbrWK5suXVF9oysHRjk+NcyO7ypyoFl/YswjSMC8sxdygRPJQSWnWF3TP2TMrXeKdHqBTw==","shasum":"c1ec77d10778d1a4694568f4d9060440322c953d","tarball":"https://registry.npmjs.org/@42how/nestjs-redis/-/nestjs-redis-1.3.4.tgz","fileCount":22,"unpackedSize":24397,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH+p972Xq2XpyPbIim1eF7RMaXOPHMBBc5zfPhqGtgvLAiEAwvTLwx1XoH/uwbZg6evT2OFWUBFwp0J7CJaaiUGMHKU="}]},"_npmUser":{"name":"42how_dev","email":"app@42how.com"},"directories":{},"maintainers":[{"name":"42how_dev","email":"app@42how.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-redis_1.3.4_1686816061943_0.34922440905829877"},"_hasShrinkwrap":false},"1.3.5":{"name":"@42how/nestjs-redis","version":"1.3.5","description":"a NestJS ioRedis module","author":{"name":"skunight"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/42how-dev/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"}},"types":"./index.d.ts","gitHead":"0b1f99ac8ec0c7f2ae64f8cd30b32b7ad324cfaf","bugs":{"url":"https://github.com/42how-dev/nestjs-redis/issues"},"homepage":"https://github.com/42how-dev/nestjs-redis#readme","_id":"@42how/nestjs-redis@1.3.5","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-mCAuNk7PEX+ainlrWKSJqjGoqu/4MTIQFCtDpuRVL5tQeKBZu+HwpT6/Rk9XJBZzvs3qDuCnZPy3Lr8TV8FnlQ==","shasum":"9473329d5aedd749a798d7c214e329d2ee4e44ca","tarball":"https://registry.npmjs.org/@42how/nestjs-redis/-/nestjs-redis-1.3.5.tgz","fileCount":22,"unpackedSize":24433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCvQcoIJARlkAS7HnV7Cq5OMaHJfJjrhl4a8UcvrEOH6wIhAP/cuunIPV3N4JAyNJ5CmFN0PWSWc5lWyXdZOZwuusU2"}]},"_npmUser":{"name":"42how_dev","email":"app@42how.com"},"directories":{},"maintainers":[{"name":"42how_dev","email":"app@42how.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-redis_1.3.5_1686816788449_0.0030417140245435625"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-15T08:01:01.856Z","1.3.4":"2023-06-15T08:01:02.162Z","modified":"2023-07-03T08:15:56.115Z","1.3.5":"2023-06-15T08:13:08.654Z"},"maintainers":[{"email":"xz87060361@126.com","name":"xz87060361"},{"email":"app@42how.com","name":"42how_dev"}],"description":"a NestJS ioRedis module","homepage":"https://github.com/42how-dev/nestjs-redis#readme","keywords":["nestjs","nest","redis","nestjs-redis"],"repository":{"type":"git","url":"git+https://github.com/42how-dev/nestjs-redis.git"},"author":{"name":"skunight"},"bugs":{"url":"https://github.com/42how-dev/nestjs-redis/issues"},"license":"MIT","readme":"\n# Nestjs Redis\n\nRedis component for NestJs.\n\n\n### Installation\n\n**Yarn**\n```bash\nyarn add @42how/nestjs-redis\n```\n\n**NPM**\n```bash\nnpm install @42how/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 '@42how/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 '@42how/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 '@42how/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"}