Comparing version 0.0.16 to 0.0.17
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96551
2002