Socket
Socket
Sign inDemoInstall

popular-cache

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popular-cache - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

lib/helper.js

6

lib/cache.js
var Item = require('./item'),
Proxy = require('./proxy');
Proxy = require('./proxy'),
helper = require('./helper');

@@ -35,2 +36,5 @@ var popular = function(options){

}
popular.prototype.memory = function() {
return helper.sizeOf(this._cache);
}
popular.prototype.set = function(key, value) {

@@ -37,0 +41,0 @@ // null value can't be cached

2

lib/proxy.js

@@ -43,3 +43,3 @@ function Proxy(cache, proxyFunc) {

if(doAccept(self, key, value, context)){
if(self.set(key, value)) self.get(key);
self.set(key, value)
}else{

@@ -46,0 +46,0 @@ // this is neither a miss, nor a hit

{
"name": "popular-cache",
"version": "1.1.6",
"version": "1.1.7",
"description": "An in-memory LRU cache with built-in statistics and proxy mode.",

@@ -5,0 +5,0 @@ "keywords": "lru, ttl, cache, memory, storage, statistics, analysis, proxy",

@@ -5,2 +5,8 @@ # Popular Cache

# Features
- Adds `memory()` to get the approximate amount of memory used (1.1.7)
- Adds `hitRate()` to get the total hit rate (1.1.6)
- Adds proxy mode (1.1.1)
# Installation

@@ -88,2 +94,6 @@

- **memory()**
- Gets the approximate amount of memory used.
- **reset()**

@@ -90,0 +100,0 @@

@@ -42,3 +42,3 @@ var assert = require('assert'),

cache.get('1'); // hit
cache.get('key'); // miss and hit
cache.get('key'); // miss
cache.get('key'); // hit

@@ -50,7 +50,7 @@ cache.get('2'); // miss and undefined can not be cached

assert.equal(3, cache.misses());
assert.equal(4, cache.hits());
assert.equal(3, cache.hits());
// popular
var expectedKeys = ['key', '1'],
expectedHits = [3, 1];
expectedHits = [2, 1];
var i = 0;

@@ -66,3 +66,3 @@ cache.popular(function(key, value, hits){

var expectedKeys = ['key', '1'],
expectedHits = [3, 1];
expectedHits = [2, 1];
var i = 0;

@@ -162,3 +162,3 @@ cache.recent(function(key, value, hits){

assert.equal(1, cache.misses());
assert.equal(1, cache.hits());
assert.equal(0, cache.hits());
}, 'world');

@@ -170,3 +170,3 @@ // should not set cache

assert.equal(1, cache.misses());
assert.equal(1, cache.hits());
assert.equal(0, cache.hits());
}, 'dont cache me');

@@ -178,3 +178,3 @@ // should set cache

assert.equal(2, cache.misses());
assert.equal(2, cache.hits());
assert.equal(0, cache.hits());
done();

@@ -181,0 +181,0 @@ }, '');

@@ -93,2 +93,9 @@ var assert = require('assert'),

})
it('should be able to get memory size', function(){
var cache = pcache({maxSize: 10, maxAge: 10});
for(var i=0; i<10; i++){
cache.set(''+i, i);
}
assert.equal(1020, cache.memory());
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc