isaacs/node-lru-cache — pull request #40 by jmendiara (2014-11-05 10:35:32+00:00)
Title: Serialization support

### Example
```js
var cache = LRU( {max: 500, maxAge: 60000})
, otherCache = LRU(50)

cache.set("key", "value");
anotherCache.load(JSON.parse(JSON.stringify(cache)));
```

### API additions
* `toJSON`: Returns a ready to be serialized array
* `load`: loads a serialized array into the current cache instantiation. Method name is the @mikeal proposal in #18

### Backwards compatibility
`true`

### Rationale
The approach taken to serialize/unload caches is KISS. Just exports the entries (`key`, `value` and `now`) and adds it to a new cache one by one. Benefits:
* The receiver cache options (`max`, `maxAge`, `length`...) can be completely different.
* Cloning caches is now possible. Using `JSON.stringify` + `JSON.parse` causes a deep copy clone
* Not exporting internal counters (`_lru`, `_mru`...) safeguards dumps against internal refactors in future versions

closes #18