0.35.0 • Published 30 days ago

@expo/entity-cache-adapter-local-memory v0.35.0

Weekly downloads
-
License
MIT
Repository
-
Last release
30 days ago

@expo/entity-cache-adapter-local-memory

Cross-request LRU cache adapter for @expo/entity. Use this cache with caution - it is nonstandard. The cache is shared between requests in the node process.

Note: This uses version 6.0.0 of node-lru-cache since it the most tuned version for our use case (low TTL + LRU). Upgrading to 7.x will cause high memory usage for the entity cache adapter use case since it allocates fixed-size data structures up front to tune for the non-TTL use case: https://github.com/isaacs/node-lru-cache/issues/208.

Documentation

Why NOT use this cache

Because this is an in-memory cache, cross-machine invalidation is not possible. Do not use this cache if you have the following use cases:

  • The objects stored are mutable
  • Reading a stale object from the cache is not acceptable in your application
  • Cross-machine invalidation is not possible

Typical use cases

If your application sees many requests fetching the same objects, you can save a trip to your cache cluster and backing datastore by using this in-memory cache. Here are some good use cases:

  • The objects stored are mostly immutable, and reading a stale object for a short TTL is acceptable
  • You have a low TTL setting in your cache

Usage

During EntityCompanionProvider instantiation:

export const createDefaultEntityCompanionProvider = (
  metricsAdapter: IEntityMetricsAdapter = new NoOpEntityMetricsAdapter()
): EntityCompanionProvider => {
  return new EntityCompanionProvider(
    metricsAdapter,
    {
      ...
    },
    {
      ['local-memory']: {
        cacheAdapterProvider: new LocalMemoryCacheAdapterProvider.getProvider(),
      },
    }
  );
};
0.35.0

30 days ago

0.34.0

30 days ago

0.33.0

7 months ago

0.32.0

11 months ago

0.31.1

1 year ago

0.31.0

1 year ago

0.30.0

1 year ago

0.29.0

2 years ago

0.28.0

2 years ago

0.27.0

2 years ago

0.26.1

2 years ago

0.26.0

2 years ago

0.25.3

2 years ago

0.25.2

2 years ago

0.25.1

2 years ago

0.25.0

2 years ago

0.24.0

2 years ago