-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave program
Description
Data Storage Layer - Cache and temporary persistence with Redis
📝 Description
Implement a storage layer using Redis to cache aggregated prices, maintain recent historical data, and facilitate fast access to prices by the API service. This layer should handle automatic expiration and provide efficient read/write methods.
Context: Aggregated prices need to be temporarily stored so the API service can query them quickly. We also need to maintain a recent history for trend calculations and analysis.
Tech Stack:
- NestJS with @nestjs/cache-manager or ioredis
- Redis as cache store
- RxJS for asynchronous operations
- TypeScript with strict types
✅ Requirements
- Implement a
StorageServicethat uses Redis as backend - Store aggregated prices with configurable TTL (e.g., 5 minutes)
- Implement methods to read/write prices by symbol
- Maintain price history (time-series) per symbol
- Implement batch operations for multiple symbols
- Handle automatic reconnection to Redis in case of failure
- Implement efficient data serialization/deserialization
- Add cache hits/misses metrics
- Configure Redis connection via environment variables
🎯 Acceptance Criteria
- The service successfully connects to Redis on startup
- Prices are stored with TTL and expire automatically
- Individual prices can be read/written by symbol
- Price history can be obtained (last N records)
- Batch operations work correctly for multiple symbols
- The service handles Redis reconnections automatically
- Cache hits/misses metrics are logged
- Unit tests exist with Redis mocks (>80% coverage)
- The data schema stored in Redis is documented
📁 Expected files to change/structure
apps/aggregator/src/services/storage.service.ts- Main serviceapps/aggregator/src/services/storage.service.spec.ts- Testsapps/aggregator/src/config/redis.config.ts- Redis configurationapps/aggregator/src/interfaces/storage-options.interface.ts- Storage optionsapps/aggregator/src/app.module.ts- Register CacheModule and serviceapps/aggregator/package.json- Add dependencies (cache-manager, ioredis)apps/aggregator/.env.example- Redis variablesapps/aggregator/README.md- Document Redis usagedocker-compose.yml(root) - Add Redis service
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave program