https://github.com/cap32/tiny-cache-store
Tiny cache store for Node.js and browser
https://github.com/cap32/tiny-cache-store
Last synced: about 2 months ago
JSON representation
Tiny cache store for Node.js and browser
- Host: GitHub
- URL: https://github.com/cap32/tiny-cache-store
- Owner: Cap32
- License: mit
- Created: 2018-11-01T11:05:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-02T09:38:53.000Z (over 7 years ago)
- Last Synced: 2025-03-18T14:57:29.392Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tiny-cache-store
[](https://travis-ci.org/Cap32/tiny-cache-store)
[](https://coveralls.io/github/Cap32/tiny-cache-store?branch=master)
[](https://github.com/Cap32/tiny-cache-store/blob/master/LICENSE.md)
[WIP] Tiny cache store for Node.js and browser
**NOTE: Usage may change before v1.0 released**
## Features
- Tiny (less than 1kb after gzip)
- High performance
- Support TTL and LRU
- Support promise
## Installation
```bash
npm install tiny-cache-store
```
## Usage
```js
import TinyCache from "tiny-cache-store";
const cache = new TinyCache();
cache.set("foo", "bar");
cache.get("foo"); // => 'bar'
cache.size(); // => 1
cache.has("foo"); // => true
cache.delete("foo"); // => true
cache.set("foo", "bar", { maxAge: 60 }); // ttl 1 minute
cache.clear();
```
#### LRU
```js
import TinyCache from "tiny-cache-store";
const cache = new TinyCache({ max: 10 });
for (let i = 0; i < 100; i++) {
cache.set(i, i);
}
cache.size(); // => 10
```
## Contributing
Contributions welcome! See the [Contributing Guide](/CONTRIBUTING.md)
## License
MIT