Comparing version 4.2.1 to 4.2.2
@@ -0,1 +1,8 @@ | ||
### 4.2.2 | ||
* Update documentation for `cached` and backends - **[@fdegiuli](https://github.com/fdegiuli)** [#27](https://github.com/groupon/node-cached/pull/27) | ||
- [`b137f56`](https://github.com/groupon/node-cached/commit/b137f56b77f1278ca6ab3680b6a0d1187941f788) **docs:** Add memory, noop backends to docs | ||
- [`e4bd666`](https://github.com/groupon/node-cached/commit/e4bd6667d8f9fa2f4017876badee9e28e9d0bd49) **docs:** Deprecate unnamed caches | ||
### 4.2.1 | ||
@@ -2,0 +9,0 @@ |
@@ -36,2 +36,3 @@ /* | ||
var _ = require('lodash'); | ||
var util = require('util'); | ||
@@ -42,4 +43,10 @@ var Cache = require('./cache'); | ||
var getName = util.deprecate(function getName(name) { | ||
return name || 'default'; | ||
}, 'Unnamed caches and caches with non-string names are deprecated.'); | ||
function cached(name, options) { | ||
name = name || 'default'; | ||
if (typeof name !== 'string') { | ||
name = getName(name); | ||
} | ||
@@ -46,0 +53,0 @@ if (!(name in namedCaches)) { |
{ | ||
"name": "cached", | ||
"version": "4.2.1", | ||
"version": "4.2.2", | ||
"description": "Simple access to a cache", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
@@ -91,2 +91,31 @@ # cached | ||
### Memory | ||
Stores all the data in an in-memory object. | ||
#### Example | ||
```js | ||
cached('myStuff', { backend: { | ||
type: 'memory' | ||
}}); | ||
``` | ||
### Noop | ||
Doesn't store data at all. All `set` operations succeed and `get` operations behave as if the value were not found in the cache. | ||
#### Examples | ||
```js | ||
cached('myStuff', { backend: { | ||
type: 'noop' | ||
}}); | ||
``` | ||
```js | ||
cached('myStuff'); | ||
``` | ||
## API | ||
@@ -98,4 +127,4 @@ | ||
* **name:** A meaningful name for what is in the cache, default: `"default"`. This will also be used as a key-prefix. If the name is `"cars"`, all keys will be prefixed with `"cars:"` | ||
* **options:** | ||
* **name:** (required) A meaningful name for what is in the cache. This will also be used as a key-prefix. If the name is `"cars"`, all keys will be prefixed with `"cars:"` | ||
* **options:** (optional) | ||
* **backend:** An object that has at least a `type` property. If no backend is configured, the cache will run in "noop"-mode, not caching anything. All other properties are forwarded to the backend, see [using different backends](#supported-backends) for which backend types exist and what options they support. | ||
@@ -102,0 +131,0 @@ * **defaults:** Defaults to apply for all cache operations. See `Cache.setDefaults` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33819
552
204