{"_id":"@cooperhu6/nestjs-redis","name":"@cooperhu6/nestjs-redis","dist-tags":{"latest":"1.3.3"},"versions":{"1.3.3":{"name":"@cooperhu6/nestjs-redis","version":"1.3.3","description":"a NestJS ioRedis module","author":{"name":"cooperhu6"},"license":"MIT","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/config":"^2.0.0","@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.6.3"},"keywords":["nestjs","nest","redis","nestjs-redis"],"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"types":"./index.d.ts","gitHead":"939f33a7f9b252e872c6edb76a3a860ed053bacf","_id":"@cooperhu6/nestjs-redis@1.3.3","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"integrity":"sha512-LrYNuNzN9evvn+ej/+Yabn+O0YPwbYgtkcCA+H8qOcQRh2Ljp/LQ6QTDMEczAVfGY1DiOzMpxPPl8TCaCJJDfw==","shasum":"443313bd1a83130678fd506260684bb89baf9bc7","tarball":"https://registry.npmjs.org/@cooperhu6/nestjs-redis/-/nestjs-redis-1.3.3.tgz","fileCount":26,"unpackedSize":25906,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGJpPvnPijGAv7Ml9GMrE6Z8b+vQIf6KePN6a/RWjNw7AiEApD9im+UelhQwQmnIyP3N27BVzvDi7qOW9msQga/s4K4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiTqBMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoMzw/+MTZcxAwiIshgbYqDTGOpd2kBST01GQTC85Kvt68OMUTwGWx3\r\nEpPIzd3Y4GzhJGNgd1LPDAOWJiIByj8u9QwefEET3J0VdVkdd6wdi0ca14+i\r\nJOiR0lr7gpq/BbnjqyEeXhlN0/Ch3BaJq64vT+zOKW1QInMiZ60VlXQiHLDZ\r\nx/Yx4Z2fZTci5tG0/aMte90dRxbL6xWzLn+Ept7ekpgssNGWFoesnPF3Rv0A\r\nI1GVFmYICgj0jorVdzvDCwjNwUbpIKVZG4okQuLRYS/hYuK2d3qqPWu2zKhg\r\n2Ym4yqV5BpILKjOR3QDjIpFdmpNRl76ajnRof7Pmc5LGhz3DAVc7eMrlyy7M\r\n9lJojAwqcTGI2JWKrA/gjiUG6RIHh35tKPfhfIB9+EbwdZ2r8xW6ltllkrJa\r\nCDb07CSfI2cuaed+ZbEU1Z8BVgE079w0HAABXtjfM1f3Xrio0+8EKoE+tyJD\r\nDxcIfa7+87cg3rI59R2+dbCC7neA2xfESJGgOKZwN6PPdREcYy4rLGW8sP8K\r\n6OojlayOCdIQ1U3vyLWsIIh4zukWzAStz2w46DCEYKIUyz8wzAEbh12Eib7r\r\nQd1u6ZVRSTVhaY8Rw1ajiOECrPndS63MXTrL8edxKCTwF6cl2DU14Xp6kCre\r\ndch1QBYDHR1+Je8oz8s2U+curNJAcsWxFWM=\r\n=U5y9\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"cooperhu6","email":"cooperhu6@gmail.com"},"directories":{},"maintainers":[{"name":"cooperhu6","email":"cooperhu6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-redis_1.3.3_1649320011939_0.26522541121355725"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-07T08:26:51.849Z","1.3.3":"2022-04-07T08:26:52.143Z","modified":"2022-04-07T08:26:52.312Z"},"maintainers":[{"name":"cooperhu6","email":"cooperhu6@gmail.com"}],"description":"a NestJS ioRedis module","keywords":["nestjs","nest","redis","nestjs-redis"],"author":{"name":"cooperhu6"},"license":"MIT","readme":"\n# Nestjs Redis\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"}