@@ -6,7 +6,7 @@ import type { StoragePort } from '../common/interfaces/storage-port.interface';
66import { ConnectionRegistry } from '../connections/connection-registry.service' ;
77import { CacheResolverService , type ResolvedCache } from './cache-resolver.service' ;
88import { CacheNotFoundError , InvalidCacheTypeError } from './errors' ;
9- import { readHashInt } from '../common/utils/valkey -fields' ;
9+ import { readIntField } from '../common/utils/record -fields' ;
1010import {
1111 THRESHOLD_RECOMMENDATIONS ,
1212 THRESHOLD_REASONINGS ,
@@ -106,10 +106,10 @@ export class CacheReadonlyService {
106106 const raw = ( await client . hgetall ( statsKey ) ) ?? { } ;
107107
108108 if ( cache . type === SEMANTIC_CACHE ) {
109- const hits = readHashInt ( raw , 'hits' ) ;
110- const misses = readHashInt ( raw , 'misses' ) ;
111- const total = readHashInt ( raw , 'total' ) || hits + misses ;
112- const costSavedMicros = readHashInt ( raw , 'cost_saved_micros' ) ;
109+ const hits = readIntField ( raw , 'hits' ) ;
110+ const misses = readIntField ( raw , 'misses' ) ;
111+ const total = readIntField ( raw , 'total' ) || hits + misses ;
112+ const costSavedMicros = readIntField ( raw , 'cost_saved_micros' ) ;
113113 const samples = await this . readSimilarityWindow ( client , cache . prefix ) ;
114114 const config = await this . readSemanticConfig ( client , cache . prefix ) ;
115115 const hitRate = total === 0 ? 0 : hits / total ;
@@ -135,14 +135,14 @@ export class CacheReadonlyService {
135135 } ;
136136 }
137137
138- const llmHits = readHashInt ( raw , 'llm:hits' ) ;
139- const llmMisses = readHashInt ( raw , 'llm:misses' ) ;
140- const toolHits = readHashInt ( raw , 'tool:hits' ) ;
141- const toolMisses = readHashInt ( raw , 'tool:misses' ) ;
138+ const llmHits = readIntField ( raw , 'llm:hits' ) ;
139+ const llmMisses = readIntField ( raw , 'llm:misses' ) ;
140+ const toolHits = readIntField ( raw , 'tool:hits' ) ;
141+ const toolMisses = readIntField ( raw , 'tool:misses' ) ;
142142 const totalHits = llmHits + toolHits ;
143143 const totalMisses = llmMisses + toolMisses ;
144144 const total = totalHits + totalMisses ;
145- const costSavedMicros = readHashInt ( raw , 'cost_saved_micros' ) ;
145+ const costSavedMicros = readIntField ( raw , 'cost_saved_micros' ) ;
146146 const tools = this . extractAgentToolStats ( raw ) ;
147147 const toolBreakdown = Object . entries ( tools )
148148 . map ( ( [ tool , s ] ) => ( {
@@ -394,10 +394,10 @@ export class CacheReadonlyService {
394394 ) : Promise < { hits : number ; misses : number ; total : number } > {
395395 const raw = ( await client . hgetall ( `${ prefix } :__stats` ) ) ?? { } ;
396396 const hits =
397- readHashInt ( raw , 'hits' ) + readHashInt ( raw , 'llm:hits' ) + readHashInt ( raw , 'tool:hits' ) ;
397+ readIntField ( raw , 'hits' ) + readIntField ( raw , 'llm:hits' ) + readIntField ( raw , 'tool:hits' ) ;
398398 const misses =
399- readHashInt ( raw , 'misses' ) + readHashInt ( raw , 'llm:misses' ) + readHashInt ( raw , 'tool:misses' ) ;
400- const explicitTotal = readHashInt ( raw , 'total' ) ;
399+ readIntField ( raw , 'misses' ) + readIntField ( raw , 'llm:misses' ) + readIntField ( raw , 'tool:misses' ) ;
400+ const explicitTotal = readIntField ( raw , 'total' ) ;
401401 return { hits, misses, total : explicitTotal === 0 ? hits + misses : explicitTotal } ;
402402 }
403403
0 commit comments