https://github.com/ruyadorno/lru-cache-fs
Extends lru-cache to add file system support
https://github.com/ruyadorno/lru-cache-fs
Last synced: about 1 month ago
JSON representation
Extends lru-cache to add file system support
- Host: GitHub
- URL: https://github.com/ruyadorno/lru-cache-fs
- Owner: ruyadorno
- License: mit
- Created: 2019-11-20T05:05:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T09:33:37.000Z (over 2 years ago)
- Last Synced: 2025-03-16T18:18:56.715Z (about 1 month ago)
- Language: JavaScript
- Size: 614 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lru-cache-fs
[](https://npmjs.org/package/lru-cache-fs)
[](https://travis-ci.org/ruyadorno/lru-cache-fs)
[](https://raw.githubusercontent.com/ruyadorno/lru-cache-fs/master/LICENSE)Extends [lru-cache](https://www.npmjs.com/package/lru-cache) to add file system support.
## Install
```
npm install lru-cache-fs
```## Usage
Retrieve cache:
```js
const Cache = require('lru-cache-fs')const cache = new Cache({
max: 100,
cacheName: "cache" // filename ref to be used
});
```By default it will use os specific paths, using [env-paths](https://www.npmjs.com/package/env-paths).
Then retrieve/set items using:
```js
cache.get('some-item') // returns whatever was stored
cache.set('some-new-item', 'foo') // sets new item and stores cache sync to fs
```The `fsDump()` method exposes an API that allows you to persist the current cache on your file system:
```js
cache.fsDump()
```All other methods from [lru-cache](https://www.npmjs.com/package/lru-cache) should be available, e.g:
```js
cache.dump() // retrieves dump of current cache memory
```## License
[MIT](LICENSE) © 2019 [Ruy Adorno](https://ruyadorno.com)