diff --git a/README.md b/README.md index 0ae4495..f571756 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ bluecache In-memory, read-through, Promises/A+, [lru-cache](https://github.com/isaacs/node-lru-cache) via [bluebird](https://github.com/petkaantonov/bluebird) -### Usage +## Usage -First, instantiate the cache, passing [options](https://github.com/kurttheviking/bluecache#options) if necessary. +First, instantiate the cache – passing [options](https://github.com/kurttheviking/bluecache#options) if necessary. ``` var BlueLRU = require("bluecache"); @@ -22,7 +22,7 @@ var options = { var cache = BlueLRU(options); ``` -Traditional LRU cache "getting" and "setting" takes place within a single call, promoting functional use. The `cache` instance is a Promise-returning function which takes two parameters: a String for the cache key and a Promise-returning function which resolves to the value to store in the cache. The cached value can be of any type. +Traditional cache "getting" and "setting" takes place within a single call, promoting functional use. The `cache` instance is a Promise-returning function which takes two parameters: a String for the cache key and a Promise-returning function which resolves to the value to store in the cache. The cached value can be of any type. ``` cache('key', function () { @@ -34,7 +34,7 @@ cache('key', function () { ``` -### Options +## Options Options are passed directly to [lru-cache](https://github.com/isaacs/node-lru-cache#options) at instantiation @@ -45,12 +45,12 @@ Options are passed directly to [lru-cache](https://github.com/isaacs/node-lru-ca - `stale`: Allow the cache to return the stale (expired via `MaxAge`) value before deleting it -### Emitted events +## Emitted events -The cache instance is also an [event emitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) which provides an `on` method against which the implementing application can listen for certain events. +The cache instance is also an [event emitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) which provides an `on` method against which the implementing application can listen for the below events. -**cache:hit** +#### cache:hit ``` { @@ -61,7 +61,7 @@ The cache instance is also an [event emitter](http://nodejs.org/api/events.html# Note: `ms` is milliseconds elapsed between cache invocation and final resolution of the cached value. -**cache:miss** +#### cache:miss ``` { @@ -72,21 +72,21 @@ Note: `ms` is milliseconds elapsed between cache invocation and final resolution Note: `ms` is milliseconds elapsed between cache invocation and final resolution of the value function. -### API +## API -**cache(key, dataFunction)** +#### cache(key, dataFunction) Attempts to get the current value of `key` from the cache. If the key exists, the "recently-used"-ness of the key is updated and the cached value is returned. If the key does not exist, the `dataFunction` is executed and the returned Promise resolved to its underlying value before being set in the cache and returned. (To support advanced cases, the key can also be a Promise for a String.) -A rejected promise is returned if either `key` or `dataFunction` are missing. +A rejected promise is returned if either `key` or `dataFunction` is missing. -**cache.del(key)** +#### cache.del(key) Returns a promise that resolves to `undefined` after deleting `key` from the cache. -**cache.on(eventName, eventHandler)** +#### cache.on(eventName, eventHandler) `eventName` is a string, corresponding to a [supported event](https://github.com/kurttheviking/bluecache#emitted-events). `eventHandler` is a function which responds to the data provided by the target event. @@ -97,17 +97,17 @@ cache.on('cache:hit', function (data) { ``` -**cache.reset()** +#### cache.reset() Returns a promise that resolves to `undefined` after removing all data from the cache. -### Contribute +## Contribute PRs are welcome! For bugs, please include a failing test which passes when your PR is applied. -### Release history +## Release history The `0.1.x` versions focused on API parity with the underlying lru-cache. However, [Bluebird promisification](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification) makes that use case unnecessary (though perhaps a bit more complicated). The `0.2.x`+ versions refocus bluecache on implementing lru-cache as a more functionally-oriented, read-through, Promises/A+ module. diff --git a/package.json b/package.json index 4410292..e109a8e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bluecache", "description": "In-memory, read-through, Promises/A+, lru-cache", - "version": "0.2.0", + "version": "0.2.1", "author": "kurttheviking ", "contributors": [ "kurttheviking "