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

node-shared-cache

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

node-shared-cache - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

test2.js

9

index.js

@@ -1,1 +0,8 @@

module.exports = require('./build/Release/binding.node');
exports = module.exports = require('./build/Release/binding.node');
exports.SIZE_64 = 6;
exports.SIZE_128 = 7;
exports.SIZE_256 = 8;
exports.SIZE_512 = 9;
exports.SIZE_1K = 10;
exports.SIZE_2K = 11;

2

package.json
{
"name": "node-shared-cache",
"version": "1.0.1",
"version": "1.1.0",
"description": "Interprocess shared memory cache for Node.JS",

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

@@ -75,10 +75,24 @@ ## node-shared-cache

function Cache(name, size)
function Cache(name, size, optional block_size)
`name` represents a file name in shared memory, `size` represents memory size in bytes to be used. Note that:
`name` represents a file name in shared memory, `size` represents memory size in bytes to be used. `block_size` denotes the size of the unit of the memory block.
- `size` should not be smaller than 557056 (544KB)
- `size` should not be larger than 2147483647 (2GB)
- `size` is 32KB aligned
`block_size` can be any of:
- cache.SIZE_64 (6): 64 bytes (default)
- cache.SIZE_128 (7): 128 bytes
- cache.SIZE_256 (8): 256 bytes
- cache.SIZE_512 (9): 512 bytes
- cache.1K (10): 1KB
- cache.2K (11): 2KB
Note that:
- `size` should not be smaller than 524288 (512KB)
- total block count (`size / (1 << block_size)`) should not be larger than 2097152
- block count is 32-aligned
- key length should not be larger than `(block_size - 32) / 2`, for example, when block size is 64 bytes, maximum key length is 16 chars.
So when block_size is set to default, the maximum memory size that can be used is 128M, and the maximum keys that can be stored is 2088960 (8192 blocks is used for data structure)
#### property setter

@@ -110,2 +124,4 @@

Block size is set to 64 and 1MB of memory is used.
### Setting property

@@ -135,4 +151,4 @@

plain obj: 229ms
shared cache: 588ms
plain obj: 236ms
shared cache: 512ms (1:2.17)

@@ -160,3 +176,3 @@ ### Getting property

read plain obj: 135ms
read shared cache: 639ms
read shared cache: 599ms (1:4.44)

@@ -181,4 +197,4 @@ When trying to read keys that are not existed:

read plain obj with key absent: 254ms
read shared cache with key absent: 538ms
read plain obj with key absent: 253ms
read shared cache with key absent: 530ms (1:2.09)

@@ -205,4 +221,4 @@ ### Enumerating properties

enumerate plain obj: 1218ms
enumerate shared cache: 4294ms
enumerate plain obj: 1189ms
enumerate shared cache: 4311ms (1:3.63)

@@ -256,6 +272,6 @@ Warn: Because the shared memory can be modified at any time even the current Node.js

JSON.stringify: 6183ms
binary serialization: 2633ms
JSON.parse: 2083ms
binary unserialization: 2225ms
JSON.stringify: 5963ms
binary serialization: 2480ms (2.40:1)
JSON.parse: 2016ms
binary unserialization: 2081ms (1:1.03)

@@ -262,0 +278,0 @@

@@ -20,3 +20,3 @@ var cp = require('child_process');

var binding = require('./build/Release/binding.node');
var obj = new binding.Cache("test", 557056);
var obj = new binding.Cache("test", 544<<10, 10);

@@ -23,0 +23,0 @@

@@ -18,3 +18,3 @@ var assert = require('assert');

var obj = new binding.Cache("test", 557056);
var obj = new binding.Cache("test", 544<<10, 10);
obj.foo = "bar";

@@ -21,0 +21,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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