Remove unnecessary context storage APIs

and rename context storage APIs
This commit is contained in:
HirokiUchikawa
2018-06-20 20:00:39 +09:00
parent dd81d947fc
commit e6411d11b1
5 changed files with 182 additions and 194 deletions

View File

@@ -180,17 +180,17 @@ function createContext(id,seed) {
obj.getAsync = function(key) {
var keyPath = parseKey(key);
var context = getContextStorage(keyPath.storage);
return context.getAsync(scope, keyPath.key);
return context.get(scope, keyPath.key);
};
obj.setAsync = function(key, value) {
var keyPath = parseKey(key);
var context = getContextStorage(keyPath.storage);
return context.setAsync(scope, keyPath.key, value);
return context.set(scope, keyPath.key, value);
};
obj.keysAsync = function(storage) {
var storageName = parseStorage(storage);
var context = getContextStorage(storageName);
return context.keysAsync(scope);
return context.keys(scope);
};
return obj;
}

View File

@@ -86,7 +86,7 @@ LocalFileSystem.prototype.close = function(){
return Promise.resolve();
}
LocalFileSystem.prototype.getAsync = function(scope, key) {
LocalFileSystem.prototype.get = function(scope, key) {
var storagePath = getStoragePath(this.storageBaseDir ,scope);
return loadFile(storagePath + ".json").then(function(data){
if(data){
@@ -99,7 +99,7 @@ LocalFileSystem.prototype.getAsync = function(scope, key) {
});
};
LocalFileSystem.prototype.setAsync =function(scope, key, value) {
LocalFileSystem.prototype.set =function(scope, key, value) {
var storagePath = getStoragePath(this.storageBaseDir ,scope);
return loadFile(storagePath + ".json").then(function(data){
var obj = data ? JSON.parse(data) : {}
@@ -113,7 +113,7 @@ LocalFileSystem.prototype.setAsync =function(scope, key, value) {
});
};
LocalFileSystem.prototype.keysAsync = function(scope){
LocalFileSystem.prototype.keys = function(scope){
var storagePath = getStoragePath(this.storageBaseDir ,scope);
return loadFile(storagePath + ".json").then(function(data){
if(data){

View File

@@ -55,18 +55,6 @@ Memory.prototype.keys = function(scope){
}
};
Memory.prototype.getAsync = function(scope, key) {
return Promise.resolve(this.get(scope, key));
};
Memory.prototype.setAsync =function(scope, key, value) {
return Promise.resolve(this.set(scope, key, value));
};
Memory.prototype.keysAsync = function(scope){
return Promise.resolve(this.keys(scope));
};
Memory.prototype.delete = function(scope){
delete this.data[scope];
return Promise.resolve();