Commit ffce55f4 authored by Tristan Cavelier's avatar Tristan Cavelier

Add JIO storage environments

Storages are now able to keep some vars in memory in their own environment.
For instance, if the storage tree is revision + local, "revision" will have an
environment and "local" will have another one.
For the futur "replicate revision storage", the environment will contain objects
in order to get the good revision for the good substorage.
Of course, if there are several "replicate revision storage", every one will have
its own environment.
parent c82e766a
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
priv.storage_spec = spec; priv.storage_spec = spec;
priv.environments = {};
// initialize // // initialize //
priv.init = function() { priv.init = function() {
// Initialize the jio id and add the new id to the list // Initialize the jio id and add the new id to the list
...@@ -38,9 +40,14 @@ ...@@ -38,9 +40,14 @@
Object.defineProperty(that,"storage",{ Object.defineProperty(that,"storage",{
configurable:false,enumerable:false,writable:false,value: configurable:false,enumerable:false,writable:false,value:
function(spec, my, forcetype) { function(spec, my, forcetype) {
var spec_str;
spec = spec || {}; spec = spec || {};
my = my || {}; my = my || {};
my.basicStorage = storage; my.basicStorage = storage;
spec_str = JSON.stringify(spec);
// environment initialization
priv.environments[spec_str] = priv.environments[spec_str] || {};
my.env = priv.environments[spec_str];
my.storage = that.storage; // NOTE : or proxy storage my.storage = that.storage; // NOTE : or proxy storage
var type = forcetype || spec.type || 'base'; var type = forcetype || spec.type || 'base';
if (type === 'base') { if (type === 'base') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment