@expo/entity-secondary-cache-redis
v0.39.0
Published
Redis secondary cache for @expo/entity
Downloads
1,222
Maintainers
Keywords
Readme
@expo/entity-secondary-cache-redis
ioredis secondary cache for @expo/entity
.
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 aRedisSecondaryEntityCache
.const secondaryCacheLoader = new TestSecondaryRedisCacheLoader( new RedisSecondaryEntityCache( redisTestEntityConfiguration, genericRedisCacheContext, (loadParams) => `${loadParams.id}` ), RedisTestEntity.loader(viewerContext) );
- Load entities through it:
const loadParams = { id: createdEntity.getID() }; const results = await secondaryCacheLoader.loadManyAsync([loadParams]);