# micro-cache

> A minimal local synchronous file system cache

Latest version **3.0.3** (published 2021-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install micro-cache
pnpm add micro-cache
yarn add micro-cache
bun add micro-cache
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2021-01-26 |
| First published | 2016-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= v12.0.0 |
| Dependencies | 2 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Marc Miles |
| Maintainers | kevintechie, ccloops, ishidas, sschadwick |
| Keywords | fs, cache, small, filesystem |

## Links

- npm: https://www.npmjs.com/package/micro-cache
- Repository: https://github.com/UWFosterIT/micro-cache
- Homepage: https://github.com/UWFosterIT/micro-cache#readme
- Issues: https://github.com/UWFosterIT/micro-cache/issues
- npm.io page: https://npm.io/package/micro-cache

## Dependencies (2)

- [sha1](https://npm.io/package/sha1.md) ^1.1.1
- [winston](https://npm.io/package/winston.md) ^3.3.3

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 3.0.3 (latest) — 2021-01-26
- 3.0.2 — 2021-01-26
- 3.0.1 — 2021-01-26
- 3.0.0 — 2021-01-26
- 2.3.0 — 2016-03-14
- 2.2.0 — 2016-03-11
- 2.1.0 — 2016-03-10
- 2.0.0 — 2016-03-07
- 1.0.2 — 2016-03-07
- 1.0.1 — 2016-03-07
- 1.0.0 — 2016-03-07

## README

A simple module to synchronously write files to a directory and read them back.  It's purpose is to act as a minimalist filesystem cache. The scope of this is limited to NodeJS (not the browser) and the file system (not runtime memory). 
                                                                                      
## INSTALL

    npm install --save micro-cache

## USE
Have a directory that you want to read and write to

    mkdir cache

Now implement this module in your script.  See ``test/index.js`` for full implementation. This uses ``winston`` for logging, you can run this as ``LOG_LEVEL=debug node index.js`` for get full output. 

```JavaScript
import MicroCache from 'micro-cache';

cache = new MicroCache('./cache');

// Write and overwrite existing
cache.write('validFileName', 'Any String Will Do');

// Write only if it doesn't exist
cache.write('anotherFileName', 'More data here', true);

// Read a file
let data = cache.read('anotherFileName');
console.log(data);

// Delete a file
cache.remove('filename');
```

## DEVELOPMENT
Pull requests are welcomed, but, if you want to add features simply just use one of the other many existing node modules that do caching.  

1. Clone the repo
2. Make your changes
3. ``npm run build``
4. ``npm run test``

---
_Source: https://npm.io/package/micro-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
