0.67.0 • Published 4d ago
@expo/entity-secondary-cache-local-memory
Licence
MIT
Version
0.67.0
Deps
2
Size
14 kB
Vulns
0
Weekly
0
@expo/entity-secondary-cache-local-memory
Cross-request LRU secondary cache for @expo/entity. Use
this cache with caution - it is nonstandard. The cache is shared between requests in the node process.
Usage
- Create a concrete implementation of abstract class
EntitySecondaryCacheLoader, in this exampleTestEntitySecondaryCacheLoader. The underlying data can come from anywhere, but an entity is constructed from the data and then authorized for the viewer. - Create an instance of your
EntitySecondaryCacheLoader, passing in aLocalMemorySecondaryEntityCache.const secondaryCacheLoader = new TestSecondaryLocalMemoryCacheLoader( new LocalMemorySecondaryEntityCache( GenericLocalMemoryCacher.createLRUCache<LocalMemoryTestEntityFields>({}), ), LocalMemoryTestEntity.loader(viewerContext), ); - Load entities through it:
const loadParams = { id: createdEntity.getID() }; const results = await secondaryCacheLoader.loadManyAsync([loadParams]);