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.1.0 to 1.2.0

src/binding.cc

12

index.js

@@ -1,3 +0,4 @@

exports = module.exports = require('./build/Release/binding.node');
process.dlopen(module, require.resolve('./build/Release/binding.node'));
exports.SIZE_DEFAULT = 6;
exports.SIZE_64 = 6;

@@ -8,2 +9,9 @@ exports.SIZE_128 = 7;

exports.SIZE_1K = 10;
exports.SIZE_2K = 11;
exports.SIZE_2K = 11;
exports.SIZE_4K = 12;
exports.SIZE_8K = 13;
exports.SIZE_16K = 14;
if(process.mainModule === module && process.argv[2] === 'release') {
process.argv.slice(3).forEach(exports.release);
}

4

package.json
{
"name": "node-shared-cache",
"version": "1.1.0",
"version": "1.2.0",
"description": "Interprocess shared memory cache for Node.JS",
"main": "index.js",
"dependencies": {
"nan": "*"
"nan": "~2.2.0"
},

@@ -9,0 +9,0 @@ "devDependencies": {},

@@ -69,2 +69,5 @@ ## node-shared-cache

test.self === test; // true
// release memory region (don't call when cache is still used by some process, may cause memory leak)
cache.release("test");
```

@@ -86,4 +89,6 @@

- cache.SIZE_512 (9): 512 bytes
- cache.1K (10): 1KB
- cache.2K (11): 2KB
- cache.SIZE_1K (10): 1KB
- cache.SIZE_2K (11): 2KB
- ...
- cache.SIZE_16K (14): 16KB

@@ -93,5 +98,5 @@ 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.
- key length should not be greater than `(block_size - 32) / 2`, for example, when block size is 64 bytes, maximum key length is 16 chars.
- key length should also not be greater than 256

@@ -104,6 +109,2 @@ 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)

Note that:
- the length of name should not be longer than 256 characters (limited by internal design)
## Performance

@@ -153,4 +154,4 @@

plain obj: 236ms
shared cache: 512ms (1:2.17)
plain obj: 227ms
shared cache: 492ms (1:2.17)

@@ -177,4 +178,4 @@ ### Getting property

read plain obj: 135ms
read shared cache: 599ms (1:4.44)
read plain obj: 138ms
read shared cache: 524ms (1:3.80)

@@ -199,4 +200,4 @@ When trying to read keys that are not existed:

read plain obj with key absent: 253ms
read shared cache with key absent: 530ms (1:2.09)
read plain obj with key absent: 265ms
read shared cache with key absent: 595ms (1:2.24)

@@ -223,4 +224,4 @@ ### Enumerating properties

enumerate plain obj: 1189ms
enumerate shared cache: 4311ms (1:3.63)
enumerate plain obj: 1201ms
enumerate shared cache: 4262ms (1:3.55)

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

JSON.stringify: 5963ms
binary serialization: 2480ms (2.40:1)
JSON.parse: 2016ms
binary unserialization: 2081ms (1:1.03)
JSON.stringify: 5876ms
binary serialization: 2523ms (2.33:1)
JSON.parse: 2042ms
binary unserialization: 2098ms (1:1.03)

@@ -280,0 +281,0 @@

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