https://github.com/guyisra/naivecache
An extremely simple and naive cache of stuff.
https://github.com/guyisra/naivecache
cache javascript nodejs
Last synced: 26 days ago
JSON representation
An extremely simple and naive cache of stuff.
- Host: GitHub
- URL: https://github.com/guyisra/naivecache
- Owner: guyisra
- Created: 2017-07-15T11:58:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-16T10:26:35.000Z (almost 9 years ago)
- Last Synced: 2025-02-28T12:43:00.689Z (over 1 year ago)
- Topics: cache, javascript, nodejs
- Language: JavaScript
- Size: 6.65 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NaïveCache
An extremely simple and naive cache of stuff.
## Quickstart
```
$ yarn add naivecache
```
# Usage
Decide what you want to cache, and how to handle misses
```
const myCache = new NaiveCacher( () =>
Promise.resolve("this is what you've been missing",
{ ttl: 86400 }
)
```
in this cases, `handleMisses` can be anything from network calls, disk calls or some other complex calculation calls
Then all you need to do is
```
myCache.get().then(result => console.log(result))
```
This will fetch the value and store it.
If you need to set the cache initially, just use `myCache.set(val)`
# Contributing
Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).
# Copyright
Copyright (c) 2017 [Guy Israeli] [@isguyra](http://twitter.com/isguyra). See [LICENSE](LICENSE) for further details.