Redis

Redis

두 번째 λ‚΄μž₯ μ „μ†‘κΈ°λŠ” Redis λ°μ΄ν„°λ² μ΄μŠ€λ₯Ό 기반으둜 ν•©λ‹ˆλ‹€. 이 νŠΈλžœμŠ€ν¬ν„°λŠ” κ²Œμ‹œ(publish)/ꡬ독(subscribe) κΈ°λŠ₯을 μ΄μš©ν•©λ‹ˆλ‹€.

Installation

μ‹œμž‘ν•˜κΈ° 전에 ν•„μš”ν•œ νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•΄μ•Όν•©λ‹ˆλ‹€.

$ npm i --save redis

Overview

TCP 전솑 μ „λž΅μ—μ„œ Redis pub/sub둜 μ „ν™˜ν•˜λ €λ©΄ createMicroservice()λ©”μ†Œλ“œμ— μ „λ‹¬λœ μ˜΅μ…˜ 객체λ₯Ό λ³€κ²½ν•΄μ•Όν•©λ‹ˆλ‹€.

@@filename(main)
const app = await NestFactory.createMicroservice(ApplicationModule, {
  transport: Transport.REDIS,
  options: {
    url: 'redis://localhost:6379',
  },
});

info 힌트 Transport μ—΄κ±°μžλŠ” @nestjs/microservices νŒ¨ν‚€μ§€μ—μ„œ κ°€μ Έμ˜΅λ‹ˆλ‹€.

Options

νŠΈλžœμŠ€ν¬ν„°μ˜ 행동을 κ²°μ •ν•˜λŠ” μ—¬λŸ¬ 가지 μ˜΅μ…˜μ΄ μžˆμŠ΅λ‹ˆλ‹€.

url

Connection url

retryAttempts

총 μ—°κ²° μ‹œλ„ 횟수

retryDelay

μ—°κ²° μž¬μ‹œλ„ 지연 μ‹œκ°„(ms)

Last updated