
Caching with Redis
Cache manager, Redis integration, cache strategies, TTL, invalidation, distributed cache
1What is Redis in the context of caching?
What is Redis in the context of caching?
Antwort
Redis (Remote Dictionary Server) is an in-memory key-value NoSQL database primarily used as a distributed cache. Unlike traditional disk-based databases, Redis stores data in RAM which provides millisecond response times. It supports advanced data structures like strings, hashes, lists, sets and sorted sets, making it highly flexible for different caching patterns.
2Which npm package should be installed to integrate Redis in NestJS?
Which npm package should be installed to integrate Redis in NestJS?
Antwort
To integrate Redis in NestJS, you need to install @nestjs/cache-manager and cache-manager-redis-store (or cache-manager-redis-yet for recent versions). The @nestjs/cache-manager package provides the official CacheModule that integrates with NestJS dependency injection system. The cache-manager-redis-store package enables using Redis as the cache backend instead of the default in-memory cache.
3Which method to use for configuring CacheModule with Redis globally?
Which method to use for configuring CacheModule with Redis globally?
Antwort
The CacheModule.register() method configures cache locally for a module, while CacheModule.registerAsync() with isGlobal: true makes it available globally throughout the application. The async approach allows injecting ConfigService to dynamically retrieve the Redis URL from environment variables. Using isGlobal avoids reimporting CacheModule in every application module.
What is TTL (Time To Live) in the Redis cache context?
What is the purpose of the @UseInterceptors(CacheInterceptor) decorator in NestJS?
+17 Interview-Fragen
Weitere Node.js / NestJS-Interviewthemen
Node.js Fundamentals
Node.js Core APIs
Asynchronous Programming
Express.js Basics
NestJS Fundamentals
REST API Design
Validation & DTO
API Documentation & Contracts
Error Handling
Unit Testing
Task Scheduling
NestJS Modules & DI
Configuration & Environment Management
JWT Authentication
Authorization & RBAC
Database with TypeORM
Prisma ORM
Middleware & Interceptors
File Upload
WebSockets
GraphQL with NestJS
End-to-End Testing
Queues with Bull
DevOps, Logging & CI/CD
Docker & Containerization
Microservices
Security Best Practices
Performance & Cloud Deployment
Meistere Node.js / NestJS für dein nächstes Interview
Zugang zu allen Fragen, Flashcards, technischen Tests, Code-Review-Übungen und Interview-Simulatoren.
Kostenlos starten