I'm trying to create a Dojox.app that reads data from a server once and then queries that data as needed during the lifetime of the app. A "dojo/store/JsonRest" will fetch the data and the "dojo/store/Memory" will be used as the cacheing repository. The process of creating the cache is straight forward for a normal dojo web page.
require(["dojo/store/JsonRest", "dojo/store/Memory", "dojo/store/Cache", "dojo/store/Observable"],
function(JsonRest, Memory, Cache, Observable){
masterStore = new JsonRest({
target: "/Inventory/"
});
cacheStore = new Memory({});
inventoryStore = new Cache(masterStore, cacheStore);
However for a Dojox.app a config.json file is used to set up the various MVC components including data stores.
The store and model portion of the json file could be similar to
"stores": {
"restStore":{
"type": "dojo/store/JsonRest",
"observable": true,
"params": {
"target": "/s/server/nowShowing.pl",
"idProperty": "filmNo"
}
},
"memoryStore": {
"type": "dojo/store/Memory",
"observable": true,
"params": {
"idProperty": "filmNo"
}
},
"filmStore": {
"type": "dojo/store/Cache",
"params": {
"masterStore": {"$ref":"#stores.restStore"},
"cachingStore": {"$ref":"#stores.memoryStore"},
"idProperty": "filmNo",
}
}
},
"models": {
"store": {
"modelLoader": "dojox/app/utils/mvcModel",
"type": "dojox/mvc/StoreRefController",
"params":{
"store": {"$ref":"#stores.filmStore"},
"query": {}
}
}
},
I know that the cache store is a wrapper and not a true store. I also know that there would be a way to configure a dojo store cache via the config.json file but I haven't been able to find out how to do it. Mr Google didn't have the answer and the dojo tests came up blank as well.
The MVC model gives application wide access to the data via the loadedStores and loadedModels parameter of each view class.
You can have a look at the tutorial here (dojox.app) and here dojox.app reference guide for creating the dojo store.