kkoomen/nestjs-throttler-storage-redis

connect aws ElastiCache with seperate read and write

mpx2m opened this issue · 1 comments

mpx2m commented

In the basic set up I have code like below, which has only one redis node:

import { Module } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { ThrottlerModule } from '@nestjs/throttler'
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis'

@Module({
  imports: [
    ThrottlerModule.forRootAsync({
      useFactory: (cfg: ConfigService) => ({
        ttl: 60,
        limit: 600,
        storage: new ThrottlerStorageRedisService({
          host: cfg.get('REDIS_HOST'),
          port: 6379
        })
      }),
      inject: [ConfigService]
    })
  ]
})
export class RateLimitingModule {}

After add another new node to aws ElastiCache, there are Primary endpoint and Reader endpoint:

Primary Endpoint: my-project.abcde.ng.0001.euc1.cache.amazonaws.com:6379
Reader Endpoint: my-project-ro.abcde.ng.0002.euc1.cache.amazonaws.com:6379

How can I set up the connection with redis so writes will arrive at Primary endpoint and reads will be Reader endpoint?

Hi,

I just released v0.2.0 which fixes a performance issue and also supports redis clusters, which seems useful for you, so try to upgrade and have a look at the updated README.