|
10 | 10 | [](https://www.npmjs.com/package/@cacheable/node-cache) |
11 | 11 | [](https://github.com/jaredwray/cacheable/blob/main/LICENSE) |
12 | 12 |
|
13 | | -`@cacheable/node-cache` is compatible with the [node-cache](https://www.npmjs.com/package/node-cache) package with regular maintenance and additional functionality (async/await and storage adapters). The only thing not implemented is the `enableLegacyCallbacks` option and functions. If you need them we are happy to take a PR to add them. |
| 13 | +`@cacheable/node-cache` is compatible with the [node-cache](https://www.npmjs.com/package/node-cache) package with regular maintenance and additional functionality (async/await and storage adapters) via `{NodeCacheStore}`. The only thing not implemented is the `enableLegacyCallbacks` option and functions. If you need them we are happy to take a PR to add them. |
14 | 14 |
|
15 | 15 | * Fully Compatible with `node-cache` using `{NodeCache}` |
16 | 16 | * Faster than the original `node-cache` package 🚀 |
| 17 | +* Storage Adapters via [Keyv](https://keyv.org) |
17 | 18 | * Async/Await functionality with `{NodeCacheStore}` |
18 | | -* Storage Adapters via [Keyv](https://keyv.org) with `{NodeCacheStore}` |
19 | 19 | * Lightweight - uses `@cacheable/utils` for utilities |
20 | 20 | * Maintained and Updated Regularly! 🎉 |
21 | 21 |
|
22 | 22 | # Table of Contents |
23 | 23 | * [Getting Started](#getting-started) |
24 | 24 | * [Basic Usage](#basic-usage) |
| 25 | +* [Breaking Changes from v1 to v2](#breaking-changes-from-v1-to-v2) |
25 | 26 | * [NodeCache Performance](#nodecache-performance) |
26 | 27 | * [NodeCache API](#nodecache-api) |
27 | 28 | * [NodeCacheStore](#nodecachestore) |
@@ -71,6 +72,34 @@ cache.set('foo', 'bar'); |
71 | 72 | cache.get('foo'); // 'bar' |
72 | 73 | ``` |
73 | 74 |
|
| 75 | +# Breaking Changes from v1 to v2 |
| 76 | + |
| 77 | +The main `NodeCache` class API has not changed and remains fully compatible. The primary internal change is that it now uses Keyv as the underlying store. |
| 78 | + |
| 79 | +## NodeCacheStore Changes |
| 80 | + |
| 81 | +### Removed `cache` Property |
| 82 | +- **V1**: `nodeCache.cache` returned a `Cacheable` instance |
| 83 | +- **V2**: Use `nodeCache.store` which returns a `Keyv` instance |
| 84 | + |
| 85 | +### Removed Storage Tiering (primary/secondary) |
| 86 | +- **V1**: Supported `primary` and `secondary` store options for multi-tier caching |
| 87 | +- **V2**: Uses single `store` option only |
| 88 | + |
| 89 | +**Migration:** |
| 90 | +```javascript |
| 91 | +// V1 |
| 92 | +const cache = new NodeCacheStore({ primary: keyv1, secondary: keyv2 }); |
| 93 | + |
| 94 | +// V2 - use single store |
| 95 | +const cache = new NodeCacheStore({ store: keyv }); |
| 96 | +``` |
| 97 | + |
| 98 | +If you need storage tiering functionality, use the `cacheable` package instead which supports primary and secondary stores. |
| 99 | + |
| 100 | +### Internal Dependency Change |
| 101 | +- V2 uses `@cacheable/utils` instead of the `cacheable` package for a lighter footprint |
| 102 | + |
74 | 103 | # NodeCache Performance |
75 | 104 |
|
76 | 105 | The performance is comparable if not faster to the original `node-cache` package, but with additional features and improvements. |
|
0 commit comments