# BAT-005: KIS 토큰 Redis 캐시 (minor-change) - Status: release-candidate - Profile: batch-lite - Source Discovery: dcy-003 (REQ-012 운영 견고성 보완) - Included REQ: REQ-016 - Excluded REQ: 없음 ## Summary - REQ-016 단일 저위험 Integration 요구사항을 minor-change 로 처리. KISBroker 에 선택적 Redis 토큰 캐시(L1 인메모리 → L2 Redis → 발급)를 더해 재기동/다중 프로세스 토큰 생존 + rate-limit 회피. orbit Redis 캐시 패턴 이식. ## Scope - In Scope: - `TokenCache` 추상화 + `RedisTokenCache`(redis.from_url, 키 `trex:broker:kis:{account_ref}:token`, app_key suffix 안전, ex=ttl) + 테스트용 인메모리 더블. - KISBroker `_ensure_token` 3-레벨 + graceful fallback. config `TREX_KIS_REDIS_URL` + daemon wiring. pyproject redis 의존. - 캐시 히트/공유/폴백/suffix 단위테스트. - Out of Scope: - 다른 캐시 백엔드(PG/파일), 토큰 외 응답 캐시. ## Documents - Planning: [planning.md](./planning.md) - Design: none (batch-lite, no external interface/flow change) - Implementation: [implementation.md](./implementation.md) - Verification: [verification.md](./verification.md) ## Notes - minor-change: 기존 BrokerPort 뒤 토큰 캐시 계층 추가, 외부 인터페이스·슬롯 흐름 불변. design 불요. - 실 Redis 없을 때도 graceful fallback → 단일 데몬 회귀 없음. 테스트는 인메모리 캐시 더블로 결정적 검증(실 Redis 서버 불요).