🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

cache-io

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-io - npm Package Compare versions

Comparing version

to
1.0.1

43

index.js
'use strict';
module.exports = function(){
this.cache = {};
this.cache = Object.create(null);

@@ -29,15 +29,25 @@ /**

/**
* Устанавливает ключ
*
*
* @param string key
* @param integer time
* @param mixed value
*
* @return object
*/
this.set = (key,time,value) => {
this.set = (key,time,value,fn) => {
this.remove(key);
if (!value) {
value = time;
time = 60;
}
time *= 1000;
this.cache[key] = {
return this.cache[key] = {
timeout: setTimeout(this._remove(key),time),
time: time,
value: value
value: value,
clear: fn
};

@@ -81,3 +91,3 @@ };

return value;
return value || null;
}

@@ -102,4 +112,10 @@

clearInterval(this.cache[key].timeout);
let cache = this.cache[key];
clearInterval(cache.timeout);
if (cache.clear) {
cache.clear();
}
delete this.cache[key];

@@ -118,2 +134,15 @@

};
/**
* Очищает хранилище
*
* @return object
*/
this.clear = () => {
for (let key in this.cache) {
this.remove(key);
}
return this;
};
};

2

package.json
{
"name": "cache-io",
"version": "1.0.0",
"version": "1.0.1",
"description": "Memory cache for node js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,4 +21,4 @@ # cache-io

```javascript
cache.set('keyName',expire,data);
// return null
cache.set('keyName',expire,data,callback);
// return value || null
```

@@ -47,2 +47,3 @@ Обновить значения истечения кэша

```
# cache-io
###English

@@ -49,0 +50,0 @@ Memory cache for node js