Socket
Socket
Sign inDemoInstall

scattered-store

Package Overview
Dependencies
8
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

2

benchmark/benchmark.js

@@ -32,3 +32,3 @@ "use strict";

var opsPerSec = Math.round(numberOfOperations / duration);
console.log(' ' + opsPerSec + " ops/s");
console.log(' ' + opsPerSec + " items/s");
}

@@ -35,0 +35,0 @@

@@ -50,8 +50,14 @@ "use strict";

var tasks = [];
var waitingForIdle = [];
var runningTask = null;
var runNextTask = function () {
if (!readyToWork || runningTask !== null || tasks.length === 0) {
if (!readyToWork || runningTask !== null) {
return;
}
if (tasks.length === 0) {
// All tasks executed, so entering "idle" mode.
informAllWaitingForIdle();
return;
}

@@ -105,2 +111,8 @@ runningTask = tasks.shift();

var informAllWaitingForIdle = function () {
while (waitingForIdle.length > 0) {
waitingForIdle.pop().resolve();
}
};
// ---------------------------------------------

@@ -133,2 +145,9 @@ // API

var whenIdle = function () {
var deferred = Q.defer();
waitingForIdle.push(deferred);
runNextTask();
return deferred.promise;
};
return {

@@ -140,3 +159,4 @@ set: set,

delete: del,
whenIdle: whenIdle,
};
};
{
"name": "scattered-store",
"description": "Key-value store for large datasets",
"version": "0.1.1",
"version": "0.1.2",
"author": "Jakub Szwacz <jakub@szwacz.com>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -29,3 +29,3 @@ scattered-store

* Implementation is very, very simple. All heavy lifting is done by file system.
* Dataset can safely grow to ridiculous sizes.
* Dataset can safely grow to ridiculous size.

@@ -35,3 +35,3 @@ ## Cons

* If the entry is 10 bytes of data, it still occupies whole block on disk.
* Every operation is a separate I/O. Not much room for performance improvements with batch tasks.
* Every operation is a separate I/O. Not much room for performance improvements with bulk tasks.

@@ -145,3 +145,14 @@

## whenIdle()
Hook to know when all queued tasks has been executed and store is idle. Useful e.g. if you want to terminate the process, and want to make sure no dataloss will occur.
**Returns:** promise
```js
store.whenIdle()
.then(function () {
// Idle now.
});
```
# Performance

@@ -157,6 +168,6 @@

Testing scattered-store performance: 20000 items, 50KB each, 977MB combined.
set... 2522 ops/s
get... 4471 ops/s
getAll... 8428 ops/s
delete... 5605 ops/s
set... 2522 items/s
get... 4471 items/s
getAll... 8428 items/s
delete... 5605 items/s
```

@@ -167,6 +178,6 @@

Testing scattered-store performance: 20000 items, 50KB each, 977MB combined.
set... 1694 ops/s
get... 4018 ops/s
getAll... 6416 ops/s
delete... 4030 ops/s
set... 1694 items/s
get... 4018 items/s
getAll... 6416 items/s
delete... 4030 items/s
```

@@ -177,6 +188,6 @@

Testing scattered-store performance: 20000 items, 50KB each, 977MB combined.
set... 726 ops/s
get... 3860 ops/s
getAll... 5071 ops/s
delete... 1130 ops/s
set... 726 items/s
get... 3860 items/s
getAll... 5071 items/s
delete... 1130 items/s
```

@@ -335,3 +335,33 @@ "use strict";

});
describe('preventing data loss', function () {
it("whenIdle fires when all tasks done", function (done) {
var setCallbackFired = false;
var store = scatteredStore.create(testDir);
store.set('abc', '123')
.then(function () {
setCallbackFired = true;
});
store.whenIdle()
.then(function () {
expect(setCallbackFired).toBe(true);
done();
});
});
it("whenIdle is called if already idle", function (done) {
var store = scatteredStore.create(testDir, function () {
// Wait for next event loop, to make sure nothing at all is happening.
setTimeout(function () {
store.whenIdle()
.then(function () {
done();
});
}, 0);
});
});
});
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc