You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a rewrite of level-ttl, not because I need it, but to make it use hooks and find out what gaps we in that API.
Problem
If a plugin like level-ttl uses the prewrite hook but also has a background job that writes to the same db, it will trigger its own hook function (as well as other hook functions). E.g.:
module.exports=functionttl(db){// Imagine a sublevel to which we write expiry metadataconstsublevel= ...
db.hooks.prewrite.add(function(op,batch){if(op.type==='put'){constexp=Date.now()+op.ttlbatch.add({type: 'put', sublevel,key: op.key,value: exp})}else{batch.add({type: 'del', sublevel,key: op.key})}})// Background jobsetInterval(functionsweep(){// Imagine we're deleting an expired keydb.del('foo').catch(..)},60e3)}
Context
I'm working on a rewrite of
level-ttl
, not because I need it, but to make it use hooks and find out what gaps we in that API.Problem
If a plugin like
level-ttl
uses theprewrite
hook but also has a background job that writes to the same db, it will trigger its own hook function (as well as other hook functions). E.g.:Solution
As well as:
The text was updated successfully, but these errors were encountered: