Skip to content

Commit 450a67f

Browse files
clean up
1 parent ab2b57b commit 450a67f

2 files changed

Lines changed: 1 addition & 17 deletions

File tree

lib/OnyxCache.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class OnyxCache {
8484
'addLastAccessedKey',
8585
'addAllSafeEvictionKeysToRecentlyAccessedList',
8686
'getKeyForEviction',
87-
'getRecentKeysSize',
8887
);
8988
}
9089

@@ -247,7 +246,6 @@ class OnyxCache {
247246
const iterator = this.recentKeys.values();
248247
const safeKeysToRemove: OnyxKey[] = [];
249248

250-
// First pass: identify safe keys to evict that aren't the most recently added key
251249
const recentKeysArray = Array.from(this.recentKeys);
252250
const mostRecentKey = recentKeysArray[recentKeysArray.length - 1];
253251

@@ -262,12 +260,7 @@ class OnyxCache {
262260
iterResult = iterator.next();
263261
}
264262

265-
// Even if we don't have enough safe keys to evict, remove all available safe keys
266-
// This will get us as close as possible to the target size without removing the most recent key
267-
const keysToRemove = safeKeysToRemove;
268-
269-
// Remove the identified keys from cache
270-
keysToRemove.forEach((key) => {
263+
safeKeysToRemove.forEach((key) => {
271264
delete this.storageMap[key];
272265
this.recentKeys.delete(key);
273266
});
@@ -364,11 +357,6 @@ class OnyxCache {
364357
getKeyForEviction(): OnyxKey | undefined {
365358
return this.recentlyAccessedKeys.find((key) => !this.evictionBlocklist[key]);
366359
}
367-
368-
/** Get the size of the recentKeys set */
369-
getRecentKeysSize(): number {
370-
return this.recentKeys.size;
371-
}
372360
}
373361

374362
const instance = new OnyxCache();

tests/unit/onyxCacheTest.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,10 +808,6 @@ describe('Onyx', () => {
808808

809809
// The trigger key should be in cache as it was just connected
810810
expect(cache.hasCacheForKey(triggerKey)).toBe(true);
811-
812-
// The cache size should exceed the configured limit (2) since
813-
// we can't remove non-evictable keys
814-
expect(cache.getRecentKeysSize()).toBeGreaterThan(2);
815811
});
816812
});
817813
});

0 commit comments

Comments
 (0)