Problem Statement
src/lib/cacheManager.ts and src/lib/redisCache.ts hardcode TTLs:
PROPERTY_LISTINGS: 5 * 60,
PROPERTY_DETAILS: 1 * 60,
SEARCH_RESULTS: 5 * 60,
AUTOCOMPLETE: 10 * 60
There is no environment-aware tuning. In dev/staging, indexes shift frequently; in production, longer TTLs are safe but invalidate stale snapshots faster than necessary. There's no per-tenant TTL override.
Expected Outcome
- TTLs are computed dynamically based on
NODE_ENV, feature flag, or per-property hotness
- A function
ttlFor(contentType, hotnessTier) returns the right seconds
- A future per-region override is one place to plug in
Acceptance Criteria
- New
src/lib/cacheTtl.ts module with documented tier mappings
- Old hardcoded constants removed from callers
- Tests verify TTL under each tier
Implementation Notes
Introduce hotness = (recentAccesses) => high | medium | low and look up from a tier table. Default tier: medium.
Files Likely Affected
src/lib/redisCache.ts
src/lib/cacheManager.ts
- Possibly:
src/lib/propertyService.ts (consumers)
Difficulty / Effort
- Difficulty: Easy
- Effort: T-Shirt S
Labels
enhancement, priority:medium, area:performance, area:caching
Problem Statement
src/lib/cacheManager.tsandsrc/lib/redisCache.tshardcode TTLs:There is no environment-aware tuning. In dev/staging, indexes shift frequently; in production, longer TTLs are safe but invalidate stale snapshots faster than necessary. There's no per-tenant TTL override.
Expected Outcome
NODE_ENV, feature flag, or per-property hotnessttlFor(contentType, hotnessTier)returns the right secondsAcceptance Criteria
src/lib/cacheTtl.tsmodule with documented tier mappingsImplementation Notes
Introduce
hotness = (recentAccesses) => high | medium | lowand look up from a tier table. Default tier:medium.Files Likely Affected
src/lib/redisCache.tssrc/lib/cacheManager.tssrc/lib/propertyService.ts(consumers)Difficulty / Effort
Labels
enhancement,priority:medium,area:performance,area:caching