@cacheable/memory 2.0.8 → 2.0.9

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.
Files changed (2) hide show
  1. package/README.md +5 -5
  2. package/package.json +2 -6
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![npm](https://img.shields.io/npm/v/@cacheable/memory.svg)](https://www.npmjs.com/package/@cacheable/memory)
9
9
  [![license](https://img.shields.io/github/license/jaredwray/cacheable)](https://github.com/jaredwray/cacheable/blob/main/LICENSE)
10
10
 
11
- You can use `CacheableMemory` as a standalone cache or as a primary store for `cacheable`. You can also set the `useClones` property to `false` if you want to use the same reference for the values. This is useful if you are using large objects and want to save memory. The `lruSize` property is the size of the LRU cache and is set to `0` by default which is unlimited. When setting the `lruSize` property it will limit the number of keys in the cache.
11
+ You can use `CacheableMemory` as a standalone cache or as a primary store for `cacheable`. You can also set the `useClones` property to `false` if you want to use the same reference for the values. This is useful if you are using large objects and want to save memory. The `lruSize` property is the size of the LRU cache and is set to `0` by default, which disables the LRU cache (no LRU eviction is performed and the cache size is bounded only by the underlying `Map` stores). When the `lruSize` property is set to a value greater than `0`, it limits the number of keys in the cache and evicts the least recently used entries when full.
12
12
 
13
13
  This simple in-memory cache uses multiple Map objects and a with `expiration` and `lru` policies if set to manage the in memory cache at scale.
14
14
 
@@ -188,11 +188,11 @@ const value = cache.get('key'); // value
188
188
 
189
189
  You can enable the LRU (Least Recently Used) feature in `CacheableMemory` by setting the `lruSize` property in the options. This will limit the number of keys in the cache to the size you set. When the cache reaches the limit it will remove the least recently used keys from the cache. This is useful if you want to limit the memory usage of the cache.
190
190
 
191
- When you set the `lruSize` we use a double linked list to manage the LRU cache and also set the `hashStoreSize` to `1` which means we will only use a single `Map` object for the LRU cache. This is because the LRU cache is managed by the double linked list and it is not possible to have more than `16,777,216 (2^24) keys` in a single `Map` object.
191
+ When you set the `lruSize`, we use a doubly linked list to track the LRU order across the underlying `Map` stores. The `lruSize` itself is capped at `16,777,216 (2^24) keys` values above this limit are rejected and an `error` event is emitted. Setting `lruSize` does not change `storeHashSize`; the underlying stores keep whatever `storeHashSize` you configured (default `16`).
192
192
 
193
193
  ```javascript
194
194
  import { CacheableMemory } from 'cacheable';
195
- const cache = new CacheableMemory({ lruSize: 1 }); // sets the LRU cache size to 1000 keys and hashStoreSize to 1
195
+ const cache = new CacheableMemory({ lruSize: 1 }); // sets the LRU cache size to 1 key
196
196
  cache.set('key1', 'value1');
197
197
  cache.set('key2', 'value2');
198
198
  const value1 = cache.get('key1');
@@ -230,7 +230,7 @@ As you can see from the benchmarks `CacheableMemory` is on par with other cachin
230
230
 
231
231
  * `ttl`: The time to live for the cache in milliseconds. Default is `undefined` which is means indefinitely.
232
232
  * `useClones`: If the cache should use clones for the values. Default is `true`.
233
- * `lruSize`: The size of the LRU cache. Default is `0` which is unlimited.
233
+ * `lruSize`: The size of the LRU cache. Default is `0`, which disables the LRU cache (no LRU eviction is performed). Maximum is `16,777,216 (2^24)`.
234
234
  * `checkInterval`: The interval to check for expired keys in milliseconds. Default is `0` which is disabled.
235
235
  * `storeHashSize`: The number of `Map` objects to use for the cache. Default is `16`.
236
236
  * `storeHashAlgorithm`: The hashing algorithm to use for the cache. Default is `djb2`. Supported: DJB2, FNV1, MURMER, CRC32.
@@ -253,7 +253,7 @@ As you can see from the benchmarks `CacheableMemory` is on par with other cachin
253
253
  * `clear()`: Clears the cache.
254
254
  * `ttl`: The default time to live for the cache in milliseconds. Default is `undefined` which is disabled.
255
255
  * `useClones`: If the cache should use clones for the values. Default is `true`.
256
- * `lruSize`: The size of the LRU cache. Default is `0` which is unlimited.
256
+ * `lruSize`: The size of the LRU cache. Default is `0`, which disables the LRU cache (no LRU eviction is performed). Maximum is `16,777,216 (2^24)`.
257
257
  * `size`: The number of keys in the cache.
258
258
  * `checkInterval`: The interval to check for expired keys in milliseconds. Default is `0` which is disabled.
259
259
  * `storeHashSize`: The number of `Map` objects to use for the cache. Default is `16`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cacheable/memory",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "High Performance In-Memory Cache for Node.js",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,9 +27,6 @@
27
27
  "license": "MIT",
28
28
  "private": false,
29
29
  "devDependencies": {
30
- "@faker-js/faker": "^10.3.0",
31
- "@types/node": "^25.3.0",
32
- "rimraf": "^6.1.3",
33
30
  "tsup": "^8.5.1",
34
31
  "typescript": "^5.9.3"
35
32
  },
@@ -37,7 +34,7 @@
37
34
  "@keyv/bigmap": "^1.3.1",
38
35
  "hookified": "^1.15.1",
39
36
  "keyv": "^5.6.0",
40
- "@cacheable/utils": "^2.4.0"
37
+ "@cacheable/utils": "^2.4.1"
41
38
  },
42
39
  "keywords": [
43
40
  "cacheable",
@@ -60,7 +57,6 @@
60
57
  ],
61
58
  "scripts": {
62
59
  "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
63
- "prepublish": "pnpm build",
64
60
  "lint": "biome check --write --error-on-warnings",
65
61
  "test": "pnpm lint && vitest run --coverage",
66
62
  "test:ci": "biome check --error-on-warnings && vitest run --coverage",