Redis Provider
This provider wires the official redis package to REDIS_URL, validates the URL with Zod, and includes small setCache / getCache / deleteCache helpers.
Features
- Zod-validated
REDIS_URL createClientconfigured from env- Optional TTL helpers for string keys (seconds or milliseconds)
- MVC and Feature architecture variants
Installation Guide
npx servercn-cli add pr redisFile Structure
MVC
-
src/configs/env.ts -
src/configs/redis.ts
Feature
-
src/shared/configs/env.ts -
src/shared/configs/redis.ts
Environment Configuration
src/configs/env.ts
Redis client and cache helpers
src/configs/redis.ts
Usage
Connect the client when your app boots (after importing the module so the client exists), then use the helpers or the raw client.
The template includes inline comment examples for OTP-style keys at the bottom of redis.ts.