https://github.com/jaredreisinger/cache-service-file-system
A plugin for cache-service that uses the local file system
https://github.com/jaredreisinger/cache-service-file-system
cache-service node npm superagent
Last synced: 6 months ago
JSON representation
A plugin for cache-service that uses the local file system
- Host: GitHub
- URL: https://github.com/jaredreisinger/cache-service-file-system
- Owner: JaredReisinger
- License: mit
- Created: 2017-01-29T06:37:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-05T20:11:01.000Z (over 7 years ago)
- Last Synced: 2025-02-10T05:26:16.666Z (8 months ago)
- Topics: cache-service, node, npm, superagent
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cache-service-file-system
A cache-service module that provides caching via the local file system.
Currently compatible with cache-service 1.3.
# Basic Usage
Require and instantiate:
```javascript
const FsCache = require('cache-service-file-system');var fsCache = new FsCache({
cacheRoot: './cache' // evaluated relative to working directory
});
```Cache!
```javascript
fsCache.set('key', 'value');
```# Configuration Options
`cache-service-file-system`'s constructor takes an optional config object with
any number of the following properties:## cacheRoot
A path to the root file-system directory to use for cached data.
* type: string
* default: './cache' (relative to working directory)## pathify
A function to customize mapping the key to a relative cache path. The default
implementation takes a key like "abc123def" and returns the path
"ab/c1/23/de/abc123def.json", which works reasonably well for relatively short
keys. You can provide a `pathify` implementation for cases where you can't
control the key directly, but need to ensure valid and short cache paths. For
example,
[superagent-cache-plugin](https://github.com/jpodwys/superagent-cache-plugin)
simply `JSON.stringify()`'s several values as a key. For a more compact/dense
cache, you can return a hash of this value.* type: function
* default: (creates a subdirectory for every two characters in the key)## readOnly
Whether the cache is read-only or not.
* type: boolean
* default: false## verbose
> When used with `cache-service`, this property is overridden by `cache-service`'s `verbose` value.
When false, `cache-service-file-system` will log only errors. When true,
`cache-service-file-system` will log all activity (useful for testing and
debugging).* type: boolean
* default: false## type
A name used for diagnostics/logs, to disambiguate between multiple instances.
* type: string
* default: 'file-system'