Fix issue #196: make memory provider DBs sharable
This commit is contained in:
parent
247ebd113a
commit
185c05e742
|
@ -1,8 +1,20 @@
|
|||
define(function(require) {
|
||||
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||
|
||||
var asyncCallback = require('async').nextTick;
|
||||
|
||||
/**
|
||||
* Make shared in-memory DBs possible when using the same name.
|
||||
*/
|
||||
var createDB = (function() {
|
||||
var pool = {};
|
||||
return function getOrCreate(name) {
|
||||
if(!pool[name]) {
|
||||
pool[name] = {};
|
||||
}
|
||||
return pool[name];
|
||||
};
|
||||
}());
|
||||
|
||||
function MemoryContext(db, readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
this.objectStore = db;
|
||||
|
@ -50,7 +62,7 @@ define(function(require) {
|
|||
|
||||
function Memory(name) {
|
||||
this.name = name || FILE_SYSTEM_NAME;
|
||||
this.db = {};
|
||||
this.db = createDB(this.name);
|
||||
}
|
||||
Memory.isSupported = function() {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue