Improve InMemoryLRUCache implementation. #2109
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains a number of commits which make the existing
InMemoryLRUCache
more whole. TheInMemoryLRUCache
— which crutches almost entirely on the excellentlru-cache
library — is the currently the default cache store which is used for REST Data Sources (i.e.RESTDataSource
) and persisted queries — though both of those can be provided more complex cache stores (e.g. distributed cache stores such as Redis/Memcached).In many cases though, the
InMemoryLRUCache
is an arguably less complex, yet still powerful, piece of machinery which can still be used to increase the performance of Apollo Server and seems deserving of a more consistent interface with the distributed stores. In that spirit, this PR brings:flush
, vialru-cache
'sreset
method.ttl
expirations (defined duringset
) vialru-cache
'smaxAge
parameter.