feat(analytics): add Redis 24h cache to neighborhood score endpoint (TEC-3072)

The GET /neighborhoods/:district/score handler was missing Redis caching.
Adds NEIGHBORHOOD_SCORE CachePrefix + CacheTTL (24h) and wires CacheService.getOrSet
into GetNeighborhoodScoreHandler. Updates handler tests to cover cache behavior.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-21 05:20:39 +07:00
parent f7bb0c0dff
commit ecb217cf5e
3 changed files with 46 additions and 5 deletions

View File

@@ -45,6 +45,8 @@ export const CacheTTL = {
MARKET_HISTORY: 21600, // 6 hours
/** AVM valuation estimate per listing — long TTL, model outputs are stable within a day */
VALUATION_LISTING: 86400, // 24 h
/** [TEC-3072] Neighborhood score — 24h TTL, POI data changes infrequently */
NEIGHBORHOOD_SCORE: 86400, // 24 h
} as const;
export enum CachePrefix {
@@ -67,6 +69,8 @@ export enum CachePrefix {
TRENDING_AREAS = 'cache:analytics:trending_areas',
PRICE_MOVERS = 'cache:analytics:price_movers',
MARKET_HISTORY = 'cache:analytics:market_history',
/** [TEC-3072] Neighborhood score per district */
NEIGHBORHOOD_SCORE = 'cache:analytics:neighborhood_score',
}
@Injectable()