feat: Use LRUCache instead of Map in MemoryCache (#774)

This commit is contained in:
Ishaan Gupta 2026-03-20 23:07:39 +05:30 committed by GitHub
parent bc9120f751
commit 239fc123b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -14,6 +14,7 @@
"@ai-sdk/anthropic": "^2.0.25",
"@ai-sdk/openai": "^2.0.23",
"ai": "^5.0.29",
"lru-cache": "^11.2.6",
"openai": "^4.104.0",
"supermemory": "^3.0.0-alpha.26",
"zod": "^4.1.5"

View file

@ -1,3 +1,4 @@
import { LRUCache } from "lru-cache"
import type { MemoryMode } from "./types"
/**
@ -5,7 +6,7 @@ import type { MemoryMode } from "./types"
* Used to cache memory retrieval results during tool-call loops within the same turn.
*/
export class MemoryCache<T = string> {
private cache: Map<string, T> = new Map()
private cache: LRUCache<string, T> = new LRUCache({ max: 100 })
/**
* Generates a cache key for the current turn based on context parameters.