Skip to content

Commit 2ea1531

Browse files
committed
f
1 parent c825c98 commit 2ea1531

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/lib/kv/adapters/vercel-runtime-cache.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class RuntimeCacheAdapter implements KvAdapter {
2323

2424
async mget<Data>(...keys: string[]) {
2525
const startTime = now();
26+
this.logger(`DEBUG: MGET called for keys: [${keys.join(', ')}]`);
2627

2728
// First check memory cache for immediate reads
2829
const memoryStartTime = now();
@@ -67,13 +68,21 @@ export class RuntimeCacheAdapter implements KvAdapter {
6768
}
6869

6970
try {
71+
this.logger(`DEBUG: Attempting to get key "${key}" from runtime cache`);
7072
const result = await cache.get(key);
73+
74+
if (result !== null && result !== undefined) {
75+
this.logger(`DEBUG: ✓ Runtime cache HIT for key "${key}" - got value: ${typeof result}`);
76+
} else {
77+
this.logger(`DEBUG: ✗ Runtime cache MISS for key "${key}" - got: ${result}`);
78+
}
7179

7280
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
7381
return result as Data | null;
7482
} catch (error) {
7583
// eslint-disable-next-line no-console
7684
console.warn(`Runtime cache get failed for key ${key}:`, error);
85+
this.logger(`DEBUG: ✗ Runtime cache ERROR for key "${key}": ${error}`);
7786

7887
return null;
7988
}
@@ -120,6 +129,7 @@ export class RuntimeCacheAdapter implements KvAdapter {
120129

121130
async set<Data>(key: string, value: Data, opts?: SetCommandOptions) {
122131
const startTime = now();
132+
this.logger(`DEBUG: SET called for key: "${key}" with value type: ${typeof value}`);
123133

124134
// Convert options for memory cache (it only supports TTL as 'ex' field)
125135
const memoryStartTime = now();
@@ -149,10 +159,14 @@ export class RuntimeCacheAdapter implements KvAdapter {
149159
}
150160

151161
// Call cache.set with options if provided, otherwise call without options
162+
this.logger(`DEBUG: Setting key "${key}" in runtime cache with options: ${JSON.stringify(runtimeCacheOptions)}`);
163+
152164
if (Object.keys(runtimeCacheOptions).length > 0) {
153165
await cache.set(key, value, runtimeCacheOptions);
166+
this.logger(`DEBUG: ✓ Runtime cache SET completed for key "${key}" WITH options`);
154167
} else {
155168
await cache.set(key, value);
169+
this.logger(`DEBUG: ✓ Runtime cache SET completed for key "${key}" WITHOUT options`);
156170
}
157171

158172
runtimeSuccess = true;

0 commit comments

Comments
 (0)