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

level-ttl

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-ttl - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

37

level-ttl.js
const after = require('after')
, xtend = require('xtend')
, encoding = require('./encoding')
, Lock = require('lock')

@@ -114,20 +115,23 @@ function prefixKey (db, key) {

ttloff(db, keys, function () {
keys.forEach(function (key) {
batch.push({ type: 'put', key: expiryKey(db, exp, key), value: encode(key) })
batch.push({ type: 'put', key: prefixKey(db, key), value: encode(exp) })
})
db._ttl._lock(keys, function (release) {
callback = release(callback || function () {})
ttloff(db, keys, function () {
keys.forEach(function (key) {
batch.push({ type: 'put', key: expiryKey(db, exp, key), value: encode(key) })
batch.push({ type: 'put', key: prefixKey(db, key), value: encode(exp) })
})
if (!batch.length)
return callback && callback()
if (!batch.length)
return callback()
batchFn(
batch
, { keyEncoding: 'binary', valueEncoding: 'binary' }
, function (err) {
if (err)
db.emit('error', err)
callback && callback()
}
)
batchFn(
batch
, { keyEncoding: 'binary', valueEncoding: 'binary' }
, function (err) {
if (err)
db.emit('error', err)
callback()
}
)
})
})

@@ -298,2 +302,3 @@ }

, _expiryNs : _prefixNs.concat(options.expiryNamespace)
, _lock : new Lock()
}

@@ -300,0 +305,0 @@

@@ -11,3 +11,3 @@ {

],
"version": "3.1.0",
"version": "3.1.1",
"homepage": "https://github.com/level/level-ttl",

@@ -32,2 +32,3 @@ "authors": [

"list-stream": ">=1.0.0 <1.1.0-0",
"lock": "~0.1.2",
"xtend": ">=4.0.0 <4.1.0-0"

@@ -39,5 +40,5 @@ },

"level-sublevel": "^6.4.6",
"ltest": "2.0.0",
"ltest": "^2.1.1",
"slump": "^2.0.0",
"tape": ">=2.14.0 <2.15.0-0",
"tape": "^4.3.0",
"bytewise": ">=0.8"

@@ -44,0 +45,0 @@ },

@@ -763,1 +763,23 @@ const tape = require('tape')

})
test('prolong entry with PUT should not duplicate the TTL key', function (t, db, createReadStream) {
var retest = function (delay, cb) {
setTimeout(function () {
db.put('bar', 'barvalue', { ttl: 20 })
verifyIn(50, createReadStream, t, function (arr) {
var count = arr.filter(function (kv) {
return /!ttl!x!\d{13}!bar/.exec(kv.key);
}).length
t.ok(count <= 1, 'contains one or zero TTL entry')
cb && cb()
})
}, delay)
}
, i
db.put('foo', 'foovalue')
for (i = 0; i < 50; i++)
retest(i)
retest(50, t.end.bind(t))
}, { checkFrequency: 5 })

Sorry, the diff of this file is not supported yet

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