Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filekv

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filekv - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

78

index.js

@@ -96,6 +96,6 @@ /**

if(exists){
queueCB.call(self,null,filePath);
queueCB(null,filePath);
cb(null,filePath);
}else{
queueCB.call(self,null,exists);
queueCB(null,exists);
cb(null,exists)

@@ -124,27 +124,33 @@ }

readFileLine(filePath,function(lineData,lineNum){
if(lineNum==0){
expireTime = parseInt(lineData+'')||0;
if(expireTime>0 && expireTime<=parseInt(Date.now()/1000)){
self.del(key);
switch(lineNum){
case 0:
queueCB.call(self,new Error('key expire'));
expireTime = parseInt(lineData+'')||0;
if(expireTime!=0 && expireTime<=parseInt(Date.now()/1000)){
self.del(key);
cb(new Error('key expire'));
return false;
}
}else if(lineNum==1){
createTime = parseInt(lineData+'')||0;
}else if(lineNum==2){ //data
try{
valueData = JSON.parse(lineData+'', function(key, value) {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value; // Buffer类型特殊处理
});
}catch(ex){
queueCB.call(self,ex);
var cbError = new Error('key expired');
queueCB(cbError);
cb(cbError);
cb(ex);
return false;
}
return false;
}
break;
case 1:
createTime = parseInt(lineData+'')||0;
break;
case 2: //data
try{
valueData = JSON.parse(lineData+'', function(key, value) {
return value && value.type === 'Buffer'
? new Buffer(value.data)
: value; // Buffer类型特殊处理
});
}catch(ex){
queueCB(ex);
cb(ex);
return false;
}
break;
}

@@ -154,8 +160,8 @@ },function(err,endType,nowLineNum){

if(err){
queueCB.call(self,err);
queueCB(err);
cb(err);
}else{
if(endType=='end'){
queueCB.call(self,null,valueData);
cb(null,valueData);
queueCB(null,valueData,createTime,expireTime);
cb(null,valueData,createTime,expireTime);
}

@@ -186,8 +192,12 @@ }

self.tool.mkdirs(filePath,function(){
self.tool.mkdirs(filePath,function(err){//TODO : this callback function's arguments need check error
if(!!err){
cb(err);
return;
}
var fileAllPath = filePath+'/'+md5key+'.fkv';
var createTime = parseInt(Date.now()/1000);
expireTime = parseInt(expireTime)||0;
if(expireTime!=0)expireTime += createTime;
var fileAllPath = filePath+'/'+md5key+'.fkv';
var valueData = null;
var createTime = parseInt(Date.now()/1000);
expireTime = parseInt(expireTime)||0;
var fileData = '';

@@ -202,2 +212,6 @@ fileData += expireTime+'\n';

queueCB.apply(self,arguments);
if(expireTime!=0 && expireTime<=createTime){
self.del(key);
}
});

@@ -204,0 +218,0 @@

{
"name": "filekv",
"version": "1.0.5",
"version": "1.0.6",
"description": "This is a key&value storage library, which uses file system to store data.",

@@ -32,3 +32,5 @@ "main": "index.js",

},
"devDependencies": {}
"devDependencies": {},
"_shasum": "2921cfe30703dbabcb4a7765501eeb7004997180",
"_from": "filekv@*"
}

@@ -1,5 +0,6 @@

# filekv
# FileKV
This is a key&value storage library, which uses file system to store data.
![filekv logo](https://raw.githubusercontent.com/zenboss/zenboss.github.io/master/images/filekv_logo.png)

@@ -6,0 +7,0 @@

@@ -7,3 +7,2 @@ "use strict";

fileDir:__dirname+'/data',
workMax:1000

@@ -44,3 +43,3 @@

fkvObj.set('test2',{name:'zenboss'},((Date.now()/1000)|0)+1,function(err1,data1){
fkvObj.set('test2',{name:'zenboss'},3600,function(err1,data1){
fkvObj.get('test2',function(err,data){

@@ -57,3 +56,3 @@ console.log(data,'test2')

fkvObj.set('test4',{name:'zenboss'},((Date.now()/1000)|0)+1,function(err1,data1){
fkvObj.set('test4',{name:'zenboss'},1,function(err1,data1){
fkvObj.get('test4',function(err,data){

@@ -64,3 +63,3 @@ console.log(data,'test4')

fkvObj.set('test5',{name:'zenboss'},((Date.now()/1000)|0)-1,function(err1,data1){
fkvObj.set('test5',{name:'zenboss'},-1,function(err1,data1){
fkvObj.get('test5',function(err,data){

@@ -67,0 +66,0 @@ console.log(data,'test5: expire test')

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