Skip to content

Commit 5377122

Browse files
committed
fix(core): improve cache retrieval in InMemoryDriver
- Enhanced the get method to parse JSON values from the cache, returning null for missing keys. - Added error handling to ensure non-JSON values are returned correctly.
1 parent 39dd581 commit 5377122

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/lib/cache/drivers/inMemory.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ export class InMemoryDriver implements CacheDriver {
1111

1212
async get<T>(key: string): Promise<T> {
1313
await this.initialiseModules();
14-
const cacheKey = `${this.options.prefix}:::${key}`;
15-
return this.client.get(cacheKey);
14+
const value = await this.client.get(`${this.options.prefix}:::${key}`);
15+
if (!value) return null;
16+
try {
17+
return JSON.parse(value);
18+
} catch (e) {
19+
return value;
20+
}
1621
}
1722

1823
async set(

0 commit comments

Comments
 (0)