@fluojs/redis 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +12 -2
- package/README.md +12 -2
- package/package.json +3 -3
package/README.ko.md
CHANGED
|
@@ -71,12 +71,22 @@ export class CacheRepository {
|
|
|
71
71
|
|
|
72
72
|
## 일반적인 패턴
|
|
73
73
|
|
|
74
|
+
### 수명 주기 소유권
|
|
75
|
+
|
|
76
|
+
`@fluojs/redis`는 `RedisModule.forRootNamed(...)`로 등록한 연결을 포함해, 자신이 생성한 모든 Redis 클라이언트의 수명 주기를 직접 관리합니다.
|
|
77
|
+
|
|
78
|
+
- 호출자가 옵션을 강제로 캐스팅하더라도 Fluo는 항상 `lazyConnect: true`를 강제하므로, 소켓은 import 시점이 아니라 애플리케이션 bootstrap 중에 열립니다.
|
|
79
|
+
- bootstrap 단계에서는 클라이언트가 ioredis `wait` 상태일 때만 lifecycle service가 `connect()`를 호출합니다.
|
|
80
|
+
- shutdown 단계에서는 ready/connecting 계열 상태에 `quit()`를 우선 시도해 정상 종료를 노리고, wait/종료 전이 상태에서는 `disconnect()`를 직접 사용합니다.
|
|
81
|
+
- `quit()`가 실패하면 Fluo는 `disconnect()`로 fallback하고, 그 뒤에도 클라이언트가 닫히지 않은 경우에만 에러를 다시 던집니다.
|
|
82
|
+
|
|
74
83
|
### 이름 있는 클라이언트
|
|
75
84
|
|
|
76
85
|
하나의 애플리케이션에서 여러 Redis 연결이 필요하면 `RedisModule.forRootNamed(name, options)`를 사용하세요. `RedisModule.forRoot(options)`는 기본 `REDIS_CLIENT`와 `RedisService` 별칭을 제공하고, 이름 있는 등록은 `getRedisClientToken(name)`과 `getRedisServiceToken(name)`으로 해석합니다.
|
|
77
86
|
|
|
78
87
|
- `name`을 생략하면 기본 별칭인 `REDIS_CLIENT` / `RedisService`를 사용합니다.
|
|
79
88
|
- `name`을 지정하면 `getRedisClientToken(name)` / `getRedisServiceToken(name)`으로 이름 있는 바인딩을 가져옵니다.
|
|
89
|
+
- 이름 있는 클라이언트도 기본 클라이언트와 동일한 bootstrap/shutdown 계약을 따르며, `REDIS_CLIENT` / `RedisService` 별칭은 기본 등록에서만 export됩니다.
|
|
80
90
|
|
|
81
91
|
```typescript
|
|
82
92
|
import { Module, Inject } from '@fluojs/core';
|
|
@@ -132,8 +142,8 @@ export class AdvancedService {
|
|
|
132
142
|
|
|
133
143
|
### 핵심 구성 요소
|
|
134
144
|
- `RedisModule`: 전역 Redis 클라이언트 등록 및 수명 주기 훅을 관리합니다.
|
|
135
|
-
- `RedisModule.forRoot(options)`: 기본 Redis 클라이언트와 `RedisService` 파사드를
|
|
136
|
-
- `RedisModule.forRootNamed(name, options)`:
|
|
145
|
+
- `RedisModule.forRoot(options)`: `lazyConnect` 수명 주기 제어를 Fluo 내부에서 유지하면서 기본 Redis 클라이언트와 `RedisService` 파사드를 등록하는 지원되는 root entrypoint입니다.
|
|
146
|
+
- `RedisModule.forRootNamed(name, options)`: 동일한 수명 주기 계약을 유지한 채 기본 별칭을 건드리지 않고 추가 Redis 클라이언트를 등록합니다.
|
|
137
147
|
- `RedisService`: JSON 코덱 지원 및 `get`/`set`/`del` 메서드를 제공하는 파사드입니다.
|
|
138
148
|
- `REDIS_CLIENT`: 내부 `ioredis` 인스턴스에 접근하기 위한 DI 토큰입니다.
|
|
139
149
|
- `getRedisClientToken(name)`: 이름 있는 raw client 토큰 헬퍼입니다. `name`을 생략하면 기본 `REDIS_CLIENT` 토큰을 돌려줍니다.
|
package/README.md
CHANGED
|
@@ -71,12 +71,22 @@ export class CacheRepository {
|
|
|
71
71
|
|
|
72
72
|
## Common Patterns
|
|
73
73
|
|
|
74
|
+
### Lifecycle Ownership
|
|
75
|
+
|
|
76
|
+
`@fluojs/redis` owns the lifecycle of every client it creates, including clients registered through `RedisModule.forRootNamed(...)`.
|
|
77
|
+
|
|
78
|
+
- Fluo always forces `lazyConnect: true`, even if callers cast options manually, so sockets open during application bootstrap instead of import time.
|
|
79
|
+
- During bootstrap, the lifecycle service only calls `connect()` while the client is still in ioredis `wait` state.
|
|
80
|
+
- During shutdown, ready/connecting clients attempt `quit()` first for graceful teardown, while wait/closed-transition states use `disconnect()` directly.
|
|
81
|
+
- If `quit()` fails, Fluo falls back to `disconnect()` and only rethrows when the client still remains open afterward.
|
|
82
|
+
|
|
74
83
|
### Named Clients
|
|
75
84
|
|
|
76
85
|
Use `RedisModule.forRootNamed(name, options)` when one application needs more than one Redis connection. `RedisModule.forRoot(options)` provides the default `REDIS_CLIENT` and `RedisService` aliases, and named registrations are resolved with `getRedisClientToken(name)` and `getRedisServiceToken(name)`.
|
|
77
86
|
|
|
78
87
|
- Omit `name` when you want the default aliases: `REDIS_CLIENT` / `RedisService`.
|
|
79
88
|
- Pass `name` when you want the named helpers: `getRedisClientToken(name)` / `getRedisServiceToken(name)`.
|
|
89
|
+
- Named clients follow the same bootstrap/shutdown contract as the default client; only the default registration exports the `REDIS_CLIENT` / `RedisService` aliases.
|
|
80
90
|
|
|
81
91
|
```typescript
|
|
82
92
|
import { Module, Inject } from '@fluojs/core';
|
|
@@ -132,8 +142,8 @@ export class AdvancedService {
|
|
|
132
142
|
|
|
133
143
|
### Core
|
|
134
144
|
- `RedisModule`: Registers the global Redis client and lifecycle hooks.
|
|
135
|
-
- `RedisModule.forRoot(options)`: Registers the default Redis client plus `RedisService` facade.
|
|
136
|
-
- `RedisModule.forRootNamed(name, options)`: Registers an additional named Redis client without replacing the default aliases.
|
|
145
|
+
- `RedisModule.forRoot(options)`: Registers the default Redis client plus `RedisService` facade, with `lazyConnect` lifecycle ownership kept inside Fluo.
|
|
146
|
+
- `RedisModule.forRootNamed(name, options)`: Registers an additional named Redis client without replacing the default aliases, using the same lifecycle contract.
|
|
137
147
|
- `RedisService`: Facade with JSON codec support and `get`/`set`/`del` methods.
|
|
138
148
|
- `REDIS_CLIENT`: DI token for the underlying `ioredis` instance.
|
|
139
149
|
- `getRedisClientToken(name)`: DI token helper for a named raw client. Omitting `name` returns the default `REDIS_CLIENT` token.
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"connection",
|
|
10
10
|
"lifecycle"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.2",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"ioredis": "^5.10.0",
|
|
40
|
-
"@fluojs/
|
|
41
|
-
"@fluojs/
|
|
40
|
+
"@fluojs/di": "^1.0.0-beta.2",
|
|
41
|
+
"@fluojs/runtime": "^1.0.0-beta.2",
|
|
42
42
|
"@fluojs/core": "^1.0.0-beta.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|