mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-06 12:51:54 +00:00
refactor(memory): implement granular cache invalidation for agents
Replaces aggressive `cache.clear()` with per-agent invalidation in `src/services/memory/index.js` to improve performance. - Adds `prune(predicate)` to `createMemoryCache`. - Updates `ingestEvents`, `runPruneCycle`, `pinMemory`, `unpinMemory`, and `markMemoryMerged` to invalidate only the affected agent's cache entries. - Adds unit test for `prune` in `test/memory-cache.test.mjs`. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
79e261d7b2
commit
60d213dec7
3 files changed
+82
-5
No files matched your search
@@ -77,3 +77,16 @@ test('blocks decrypted/session-sensitive data from durable promotion without san
|
||||
assert.equal(events[1].durable_eligible, true);
|
||||
assert.equal(cache.getMetrics().runtime_sensitive_events_blocked, 1);
|
||||
});
|
||||
|
||||
test('prunes cache entries based on predicate', () => {
|
||||
const cache = createMemoryCache();
|
||||
cache.set('key1', 'value1');
|
||||
cache.set('key2', 'value2');
|
||||
cache.set('other', 'value3');
|
||||
|
||||
cache.prune((key) => key.startsWith('key'));
|
||||
|
||||
assert.equal(cache.get('key1'), undefined);
|
||||
assert.equal(cache.get('key2'), undefined);
|
||||
assert.equal(cache.get('other'), 'value3');
|
||||
});
|
||||
Reference in new issue
Block a user