debug(chart): add cache logging to debug cache misses
This commit is contained in:
@@ -70,11 +70,16 @@ function setCached(key: string, data: SuggestChartsResponse): void {
|
||||
export async function suggestCharts(request: SuggestChartsRequest): Promise<SuggestChartsResponse> {
|
||||
// Check cache first
|
||||
const cacheKey = getCacheKey(request.content || '', request.selection)
|
||||
console.log('[suggestCharts] Cache key:', cacheKey, 'contentLen:', request.content?.length, 'selectionLen:', request.selection?.length)
|
||||
|
||||
const cached = getCached(cacheKey)
|
||||
if (cached) {
|
||||
console.log('[suggestCharts] CACHE HIT - returning cached data')
|
||||
return cached
|
||||
}
|
||||
|
||||
console.log('[suggestCharts] CACHE MISS - calling API')
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/ai/suggest-charts', {
|
||||
method: 'POST',
|
||||
@@ -104,6 +109,9 @@ export async function suggestCharts(request: SuggestChartsRequest): Promise<Sugg
|
||||
// Cache successful responses
|
||||
if (!data.error && !data.quotaExceeded) {
|
||||
setCached(cacheKey, data)
|
||||
console.log('[suggestCharts] Cached response for key:', cacheKey, 'cache size now:', cache.size)
|
||||
} else {
|
||||
console.log('[suggestCharts] NOT caching (has error or quota exceeded)')
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user