Skip to content

Commit 05ce3cf

Browse files
authored
node-cache - doc: adding in breaking changes from v1 to v2 (#1547)
1 parent b85f03a commit 05ce3cf

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

packages/node-cache/README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
[![npm](https://img.shields.io/npm/v/@cacheable/node-cache)](https://www.npmjs.com/package/@cacheable/node-cache)
1111
[![license](https://img.shields.io/github/license/jaredwray/cacheable)](https://github.com/jaredwray/cacheable/blob/main/LICENSE)
1212

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.
1414

1515
* Fully Compatible with `node-cache` using `{NodeCache}`
1616
* Faster than the original `node-cache` package 🚀
17+
* Storage Adapters via [Keyv](https://keyv.org)
1718
* Async/Await functionality with `{NodeCacheStore}`
18-
* Storage Adapters via [Keyv](https://keyv.org) with `{NodeCacheStore}`
1919
* Lightweight - uses `@cacheable/utils` for utilities
2020
* Maintained and Updated Regularly! 🎉
2121

2222
# Table of Contents
2323
* [Getting Started](#getting-started)
2424
* [Basic Usage](#basic-usage)
25+
* [Breaking Changes from v1 to v2](#breaking-changes-from-v1-to-v2)
2526
* [NodeCache Performance](#nodecache-performance)
2627
* [NodeCache API](#nodecache-api)
2728
* [NodeCacheStore](#nodecachestore)
@@ -71,6 +72,34 @@ cache.set('foo', 'bar');
7172
cache.get('foo'); // 'bar'
7273
```
7374

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+
74103
# NodeCache Performance
75104

76105
The performance is comparable if not faster to the original `node-cache` package, but with additional features and improvements.

0 commit comments

Comments
 (0)