@expo/entity-cache-adapter-local-memory 0.25.2 → 0.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,23 +3,26 @@
3
3
  Cross-request [LRU](https://github.com/isaacs/node-lru-cache) cache adapter for `@expo/entity`. Use
4
4
  this cache with caution - it is nonstandard. The cache is shared between requests in the node process.
5
5
 
6
+ 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
7
+ 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.
8
+
6
9
  [Documentation](https://expo.github.io/entity/modules/_expo_cache_adapter_local_memory.html)
7
10
 
8
11
  ## Why NOT use this cache
9
12
 
10
- Because this is an in-memory cache, cross-box invalidation is not possible. Do not use this cache
13
+ Because this is an in-memory cache, cross-machine invalidation is not possible. Do not use this cache
11
14
  if you have the following use cases:
12
15
 
13
- - The objects stored have high mutability
16
+ - The objects stored are mutable
14
17
  - Reading a stale object from the cache is not acceptable in your application
15
- - Cross-box invalidation is not possible
18
+ - Cross-machine invalidation is not possible
16
19
 
17
20
  ## Typical use cases
18
21
 
19
22
  If your application sees many requests fetching the same objects, you can save a trip to your cache
20
23
  cluster and backing datastore by using this in-memory cache. Here are some good use cases:
21
24
 
22
- - The objects stored are mostly immutable
25
+ - The objects stored are mostly immutable, and reading a stale object for a short TTL is acceptable
23
26
  - You have a low TTL setting in your cache
24
27
 
25
28
  ## Usage
@@ -14,23 +14,20 @@ class GenericLocalMemoryCacher {
14
14
  this.localMemoryCache = localMemoryCache;
15
15
  }
16
16
  static createLRUCache(options = {}) {
17
- var _a, _b, _c;
17
+ var _a, _b;
18
18
  const DEFAULT_LRU_CACHE_MAX_AGE_SECONDS = 10;
19
19
  const DEFAULT_LRU_CACHE_SIZE = 10000;
20
20
  const maxAgeSeconds = (_a = options.ttlSeconds) !== null && _a !== void 0 ? _a : DEFAULT_LRU_CACHE_MAX_AGE_SECONDS;
21
- const lruCacheOptions = {
21
+ return new lru_cache_1.default({
22
22
  max: (_b = options.maxSize) !== null && _b !== void 0 ? _b : DEFAULT_LRU_CACHE_SIZE,
23
- maxSize: (_c = options.maxSize) !== null && _c !== void 0 ? _c : DEFAULT_LRU_CACHE_SIZE,
24
- sizeCalculation: (value) => value === exports.DOES_NOT_EXIST_LOCAL_MEMORY_CACHE ? 0 : 1,
25
- ttl: maxAgeSeconds * 1000, // convert to ms
26
- };
27
- return new lru_cache_1.default(lruCacheOptions);
23
+ length: (value) => (value === exports.DOES_NOT_EXIST_LOCAL_MEMORY_CACHE ? 0 : 1),
24
+ maxAge: maxAgeSeconds * 1000, // convert to ms
25
+ });
28
26
  }
29
27
  static createNoOpCache() {
30
28
  return new lru_cache_1.default({
31
- max: 1,
32
- maxSize: 1,
33
- sizeCalculation: () => 10, // make all things larger than max size
29
+ max: 0,
30
+ maxAge: -1,
34
31
  });
35
32
  }
36
33
  async loadManyAsync(keys) {
@@ -68,7 +65,7 @@ class GenericLocalMemoryCacher {
68
65
  }
69
66
  async invalidateManyAsync(keys) {
70
67
  for (const key of keys) {
71
- this.localMemoryCache.delete(key);
68
+ this.localMemoryCache.del(key);
72
69
  }
73
70
  }
74
71
  makeCacheKey(parts) {
@@ -1 +1 @@
1
- {"version":3,"file":"GenericLocalMemoryCacher.js","sourceRoot":"","sources":["../src/GenericLocalMemoryCacher.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAkF;AAClF,0DAAiC;AAEjC,+EAA+E;AAC/E,qEAAqE;AACxD,QAAA,iCAAiC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AA0ExE,MAAqB,wBAAwB;IAC3C,YAA6B,gBAA2C;QAA3C,qBAAgB,GAAhB,gBAAgB,CAA2B;IAAG,CAAC;IAE5E,MAAM,CAAC,cAAc,CACnB,UAAqD,EAAE;;QAEvD,MAAM,iCAAiC,GAAG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,CAAC;aACJ;iBAAM;gBACL,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE;oBACpB,MAAM,EAAE,oBAAW,CAAC,IAAI;iBACzB,CAAC,CAAC;aACJ;SACF;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,SAAiD;QAC3E,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,SAAS,EAAE;YACnC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SACtC;IACH,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,IAAuB;QACrD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,yCAAiC,CAAC,CAAC;SACnE;IACH,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,IAAuB;QACtD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAChC;IACH,CAAC;IAEM,YAAY,CAAC,KAAe;QACjC,MAAM,SAAS,GAAG,GAAG,CAAC;QACtB,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,SAAS,EAAE,CAAC,CAChE,CAAC;QACF,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACF;AAxED,2CAwEC"}
@@ -9,8 +9,7 @@ describe(GenericLocalMemoryCacher_1.default, () => {
9
9
  it('creates a cache with default options', () => {
10
10
  const cache = GenericLocalMemoryCacher_1.default.createLRUCache();
11
11
  expect(cache.max).toBe(10000);
12
- expect(cache.maxSize).toBe(10000);
13
- expect(cache.ttl).toBe(10000);
12
+ expect(cache.maxAge).toBe(10000);
14
13
  });
15
14
  it('respects specified options', () => {
16
15
  const cache = GenericLocalMemoryCacher_1.default.createLRUCache({
@@ -18,8 +17,7 @@ describe(GenericLocalMemoryCacher_1.default, () => {
18
17
  maxSize: 10,
19
18
  });
20
19
  expect(cache.max).toBe(10);
21
- expect(cache.maxSize).toBe(10);
22
- expect(cache.ttl).toBe(3000);
20
+ expect(cache.maxAge).toBe(3000);
23
21
  });
24
22
  });
25
23
  describe(GenericLocalMemoryCacher_1.default.createNoOpCache, () => {
@@ -1 +1 @@
1
- {"version":3,"file":"GenericLocalMemoryCacher-test.js","sourceRoot":"","sources":["../../src/__tests__/GenericLocalMemoryCacher-test.ts"],"names":[],"mappings":";;;;;AAAA,2FAAmE;AAEnE,QAAQ,CAAC,kCAAwB,EAAE,GAAG,EAAE;IACtC,QAAQ,CAAC,kCAAwB,CAAC,cAAc,EAAE,GAAG,EAAE;QACrD,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,KAAK,GAAG,kCAAwB,CAAC,cAAc,EAAE,CAAC;YACxD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;YACpC,MAAM,KAAK,GAAG,kCAAwB,CAAC,cAAc,CAAC;gBACpD,UAAU,EAAE,CAAC;gBACb,OAAO,EAAE,EAAE;aACZ,CAAC,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI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,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kCAAwB,CAAC,eAAe,EAAE,GAAG,EAAE;QACtD,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;YAC/B,MAAM,KAAK,GAAG,kCAAwB,CAAC,eAAe,EAAsB,CAAC;YAC7E,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YACnC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/entity-cache-adapter-local-memory",
3
- "version": "0.25.2",
3
+ "version": "0.25.3",
4
4
  "description": "Cross-request local memory cache adapter for @expo/entity",
5
5
  "files": [
6
6
  "build",
@@ -30,9 +30,9 @@
30
30
  "@expo/entity": "*"
31
31
  },
32
32
  "dependencies": {
33
- "lru-cache": "^7.3.1"
33
+ "lru-cache": "^6.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@expo/entity": "^0.25.2"
36
+ "@expo/entity": "^0.25.3"
37
37
  }
38
38
  }
@@ -7,76 +7,6 @@ export const DOES_NOT_EXIST_LOCAL_MEMORY_CACHE = Symbol('doesNotExist');
7
7
  type LocalMemoryCacheValue<TFields> = Readonly<TFields> | typeof DOES_NOT_EXIST_LOCAL_MEMORY_CACHE;
8
8
  export type LocalMemoryCache<TFields> = LRUCache<string, LocalMemoryCacheValue<TFields>>;
9
9
 
10
- type LRUCacheOptionsV7<K, V> = {
11
- /**
12
- * the number of most recently used items to keep.
13
- * note that we may store fewer items than this if maxSize is hit.
14
- */
15
- max: number;
16
-
17
- /**
18
- * if you wish to track item size, you must provide a maxSize
19
- * note that we still will only keep up to max *actual items*,
20
- * so size tracking may cause fewer than max items to be stored.
21
- * At the extreme, a single item of maxSize size will cause everything
22
- * else in the cache to be dropped when it is added. Use with caution!
23
- * Note also that size tracking can negatively impact performance,
24
- * though for most cases, only minimally.
25
- */
26
-
27
- maxSize?: number;
28
-
29
- /**
30
- * function to calculate size of items. useful if storing strings or
31
- * buffers or other items where memory size depends on the object itself.
32
- * also note that oversized items do NOT immediately get dropped from
33
- * the cache, though they will cause faster turnover in the storage.
34
- */
35
- sizeCalculation?: (value: V, key: K) => number;
36
-
37
- /**
38
- * function to call when the item is removed from the cache
39
- * Note that using this can negatively impact performance.
40
- */
41
- dispose?: (value: V, key: K) => void;
42
-
43
- /**
44
- * max time to live for items before they are considered stale
45
- * note that stale items are NOT preemptively removed by default,
46
- * and MAY live in the cache, contributing to its LRU max, long after
47
- * they have expired.
48
- * Also, as this cache is optimized for LRU/MRU operations, some of
49
- * the staleness/TTL checks will reduce performance, as they will incur
50
- * overhead by deleting items.
51
- * Must be a positive integer in ms, defaults to 0, which means "no TTL"
52
- */
53
- ttl?: number;
54
-
55
- /**
56
- * return stale items from cache.get() before disposing of them
57
- * boolean, default false
58
- */
59
- allowStale?: boolean;
60
-
61
- /**
62
- * update the age of items on cache.get(), renewing their TTL
63
- * boolean, default false
64
- */
65
- updateAgeOnGet?: boolean;
66
-
67
- /**
68
- * update the age of items on cache.has(), renewing their TTL
69
- * boolean, default false
70
- */
71
- updateAgeOnHas?: boolean;
72
-
73
- /**
74
- * update the "recently-used"-ness of items on cache.has()
75
- * boolean, default false
76
- */
77
- updateRecencyOnHas?: boolean;
78
- };
79
-
80
10
  export default class GenericLocalMemoryCacher<TFields> implements IEntityGenericCacher<TFields> {
81
11
  constructor(private readonly localMemoryCache: LocalMemoryCache<TFields>) {}
82
12
 
@@ -86,21 +16,17 @@ export default class GenericLocalMemoryCacher<TFields> implements IEntityGeneric
86
16
  const DEFAULT_LRU_CACHE_MAX_AGE_SECONDS = 10;
87
17
  const DEFAULT_LRU_CACHE_SIZE = 10000;
88
18
  const maxAgeSeconds = options.ttlSeconds ?? DEFAULT_LRU_CACHE_MAX_AGE_SECONDS;
89
- const lruCacheOptions: LRUCacheOptionsV7<string, TFields> = {
19
+ return new LRUCache<string, LocalMemoryCacheValue<TFields>>({
90
20
  max: options.maxSize ?? DEFAULT_LRU_CACHE_SIZE,
91
- maxSize: options.maxSize ?? DEFAULT_LRU_CACHE_SIZE,
92
- sizeCalculation: (value: LocalMemoryCacheValue<TFields>) =>
93
- value === DOES_NOT_EXIST_LOCAL_MEMORY_CACHE ? 0 : 1,
94
- ttl: maxAgeSeconds * 1000, // convert to ms
95
- };
96
- return new LRUCache<string, LocalMemoryCacheValue<TFields>>(lruCacheOptions as any);
21
+ length: (value) => (value === DOES_NOT_EXIST_LOCAL_MEMORY_CACHE ? 0 : 1),
22
+ maxAge: maxAgeSeconds * 1000, // convert to ms
23
+ });
97
24
  }
98
25
 
99
26
  static createNoOpCache<TFields>(): LocalMemoryCache<TFields> {
100
27
  return new LRUCache<string, LocalMemoryCacheValue<TFields>>({
101
- max: 1,
102
- maxSize: 1,
103
- sizeCalculation: () => 10, // make all things larger than max size
28
+ max: 0,
29
+ maxAge: -1,
104
30
  });
105
31
  }
106
32
 
@@ -142,7 +68,7 @@ export default class GenericLocalMemoryCacher<TFields> implements IEntityGeneric
142
68
 
143
69
  public async invalidateManyAsync(keys: readonly string[]): Promise<void> {
144
70
  for (const key of keys) {
145
- this.localMemoryCache.delete(key);
71
+ this.localMemoryCache.del(key);
146
72
  }
147
73
  }
148
74
 
@@ -5,8 +5,7 @@ describe(GenericLocalMemoryCacher, () => {
5
5
  it('creates a cache with default options', () => {
6
6
  const cache = GenericLocalMemoryCacher.createLRUCache();
7
7
  expect(cache.max).toBe(10000);
8
- expect(cache.maxSize).toBe(10000);
9
- expect(cache.ttl).toBe(10000);
8
+ expect(cache.maxAge).toBe(10000);
10
9
  });
11
10
 
12
11
  it('respects specified options', () => {
@@ -15,8 +14,7 @@ describe(GenericLocalMemoryCacher, () => {
15
14
  maxSize: 10,
16
15
  });
17
16
  expect(cache.max).toBe(10);
18
- expect(cache.maxSize).toBe(10);
19
- expect(cache.ttl).toBe(3000);
17
+ expect(cache.maxAge).toBe(3000);
20
18
  });
21
19
  });
22
20