feat(api): add @Cacheable decorator and plan list caching
- Create @Cacheable method decorator for declarative cache-aside pattern with configurable prefix, TTL, resource label, and key extraction - Add PLAN_LIST (1h TTL) and REFERENCE_DATA (24h TTL) cache constants - Add CachePrefix.PLAN_LIST and CachePrefix.REFERENCE entries - Cache subscription plan queries in GetPlanHandler (single + list) - Export Cacheable decorator from shared module barrel - Add comprehensive tests for decorator and handler caching The caching infrastructure (CacheService, Redis, Prometheus metrics, event-driven invalidation) was already production-ready with 10+ hot paths cached. This commit adds the missing declarative decorator and plan list caching. Resolves: TEC-1567 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -24,6 +24,10 @@ export const CacheTTL = {
|
||||
USER_PROFILE: 600, // 10 min
|
||||
/** User quota — very short TTL, invalidated on usage metering and plan changes */
|
||||
USER_QUOTA: 60, // 1 min
|
||||
/** Subscription plan list — long TTL, rarely changes */
|
||||
PLAN_LIST: 3600, // 1 hour
|
||||
/** Reference data (districts, wards) — very long TTL, static data */
|
||||
REFERENCE_DATA: 86400, // 24 hours
|
||||
} as const;
|
||||
|
||||
export enum CachePrefix {
|
||||
@@ -37,6 +41,8 @@ export enum CachePrefix {
|
||||
USER_PROFILE = 'cache:user:profile',
|
||||
USER_QUOTA = 'cache:user:quota',
|
||||
VALUATION = 'cache:valuation',
|
||||
PLAN_LIST = 'cache:plan:list',
|
||||
REFERENCE = 'cache:reference',
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
||||
Reference in New Issue
Block a user