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

p-odm

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-odm - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

4

lib/cache.js

@@ -5,4 +5,4 @@ 'use strict';

this.store = {};
options = options || {cacheSize: 256, ttl: 30000};
this.size = options.cacheSize || 256;
options = options || {cacheSize: 262144, ttl: 30000};
this.size = options.cacheSize || 262144;
this.ttl = options.ttl || 30000;

@@ -9,0 +9,0 @@ this.keys = 0;

@@ -1435,2 +1435,4 @@ 'use strict';

var i;
var idsToFind = [];
var result = [];

@@ -1442,10 +1444,32 @@ for (i = 0; i < ids.length; i++) {

if (index[ids[i].toHexString()] === undefined) {
index[ids[i].toHexString()] = [i];
if (l2cache) {
var cachedDoc = isCached(odm.queryCache, mongoCollection, '_id', ids[i]);
if (cachedDoc !== undefined) {
result[i] = new Model(cachedDoc, { deserialize: true });
} else {
idsToFind.push(ids[i]);
// build index for the missing data
if (index[ids[i].toHexString()] === undefined) {
index[ids[i].toHexString()] = [i];
} else {
index[ids[i].toHexString()].push(i);
}
}
} else {
index[ids[i].toHexString()].push(i);
idsToFind.push(ids[i]);
// build index for the missing data
if (index[ids[i].toHexString()] === undefined) {
index[ids[i].toHexString()] = [i];
} else {
index[ids[i].toHexString()].push(i);
}
}
}
this.find({_id: {'$in': ids}}, fields, options, function (err, models) {
// all items were already cached
if (idsToFind.length === 0) {
return callback(null, result);
}
this.find({_id: {'$in': idsToFind}}, fields, options, function (err, models) {
if (err) {

@@ -1455,3 +1479,2 @@ return callback(err);

var result = [];
var i, j;

@@ -1461,2 +1484,6 @@

for (i = 0; i < models.length; i++) {
if (l2cache) {
putToCache(odm.queryCache, mongoCollection, '_id', models[i]._id, models[i]._internalDocument);
}
var indexes = index[models[i]._id.toHexString()];

@@ -1463,0 +1490,0 @@ for (j = 0; j < indexes.length; j++) {

@@ -8,3 +8,3 @@ {

],
"version": "0.0.16",
"version": "0.0.17",
"engines": {

@@ -11,0 +11,0 @@ "node": ">=0.4.12"

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