Skip to content

Commit a57f2a5

Browse files
dlongleydavidlehn
authored andcommitted
Clear entire cache when it fills.
- Assumes situations where the cache fills likely means the cache isn't being used that efficiently anyway -- and deleting one entry each time the cache gets a new entry once filled will be slow.
1 parent a3ec206 commit a57f2a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/context.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,11 @@ api.getInitialContext = (options) => {
647647
getInverse: _createInverseContext,
648648
clone: _cloneActiveContext
649649
};
650+
// TODO: consider using LRU cache instead
650651
if(INITIAL_CONTEXT_CACHE.size === INITIAL_CONTEXT_CACHE_MAX_SIZE) {
651-
INITIAL_CONTEXT_CACHE.delete(INITIAL_CONTEXT_CACHE.keys().next().value);
652+
// clear whole cache -- assumes scenario where the cache fills means
653+
// the cache isn't being used very efficiently anyway
654+
INITIAL_CONTEXT_CACHE.clear();
652655
}
653656
INITIAL_CONTEXT_CACHE.set(key, initialContext);
654657
return initialContext;

0 commit comments

Comments
 (0)