https://github.com/floatdrop/cacha
Cache on file-system
https://github.com/floatdrop/cacha
Last synced: 9 months ago
JSON representation
Cache on file-system
- Host: GitHub
- URL: https://github.com/floatdrop/cacha
- Owner: floatdrop
- License: mit
- Created: 2015-11-11T08:27:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-15T07:53:33.000Z (over 10 years ago)
- Last Synced: 2025-06-30T14:45:19.105Z (11 months ago)
- Language: JavaScript
- Size: 0 Bytes
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# cacha [](https://travis-ci.org/floatdrop/cacha)
> Cache on file-system
## Install
```
$ npm install --save cacha
```
## Usage
```js
const Cache = require('cacha');
const cache = new Cacha('.my/cache');
cache.set('id', 'content');
//=> Promise
cache.get('id');
//=> Promise with 'content'
```
## API
### cacha(namespace, [options])
#### namespace
Type: `string`
Directory in HOME or TMP directory of current user.
If namespace begins with `/` it will be interpreted as absolute path.
#### options
##### ttl
Type: `Number`
Default: `86400000`
How long (in milliseconds) keep entries in cache.
### cache.get(id, [options])
### cache.getSync(id, [options])
### cache.set(id, content, [options])
### cache.setSync(id, content, [options])
Get and set methods for cache entries. `options` are passed to `fs` write and read methods (for example to specify encoding).
### cache.clean()
Removes outdated entries in cache.
## License
MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)