record-cache
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -78,2 +78,3 @@ var EMPTY = [] | ||
this._onstale = opts.onStale || opts.onstale || null | ||
this._fresh = new RecordStore() | ||
@@ -135,2 +136,3 @@ this._stale = new RecordStore() | ||
RecordCache.prototype._gc = function () { | ||
if (this._onstale && this._stale.size > 0) this._onstale(this._stale) | ||
this._stale = this._fresh | ||
@@ -137,0 +139,0 @@ this._fresh = new RecordStore() |
{ | ||
"name": "record-cache", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Cache optimised for record like things", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,3 +44,4 @@ # record-cache | ||
maxSize: 1000, // approximate max size | ||
maxAge: 1000 // approximate max age in ms | ||
maxAge: 1000, // approximate max age in ms | ||
onStale: false // function called when evicting stale records | ||
} | ||
@@ -50,3 +51,3 @@ ``` | ||
In the worst case the cache will be `2 * maxSize` large, and | ||
if maxAge is used old values are gc'ed every `0.66 * maxAge - 1.33 * maxAge`. | ||
if `maxAge` is used old values are gc'ed every `0.66 * maxAge - 1.33 * maxAge` with an optional callback to the `onStale` function upon record eviction. | ||
@@ -53,0 +54,0 @@ This is to greatly simplify the data structures and also gives us a pretty decent |
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
11552
291
84