« Return to Thread: Restful server does not check 'cached' items for query

Re: Restful server does not check 'cached' items for query

by V S P :: Rate this Message:

Reply to Author | View in Thread

Wanted to add to my question

a) the data I am searching is 'comitted' in the store

b) I also tried dojox.data.PersevereStore
and I am getting behavior that is hard for me to explain:


Here is the sequence

a) add to store, and save

b) add to store and save


c) query store for 2nd item -- , the Perserver store issues a query
to the server (my server now returns empty),
then it finds the item (I presume from local cache)


d) query store for 1st item -- the Perserver store issues query to
the server (my server again returns empty) -- and then
the store does Not find anything


So both c) and d) do something that I do not want them to do (issue a
query)
on the item that is already in memory on the client

and then they also behave somewhat different depending on what item I am
looking for

I created the Perserver store with the following options


----------------------------------------------------------
var crmService = function(query, queryOptions) {
console.log('calling query');
return dojo.xhrGet({url:"services",
handleAs:'json',content:{action:'query',query:query,
queryOptions:queryOptions}});
}

crmService.put = function(id, value) {
console.log('calling update');
        return dojo.xhrPost(
        {url:"updateService", handleAs:'json',
        content:{action:"update", id:id, value:value}});
}

crmService.post = function(id, value) {
console.log('calling add');
return dojo.xhrPost({url:"addService", handleAs:'json',
        content:{action:'add',id:id, value:value}});
}

crmService['delete'] = function(id) {
console.log('calling delete');
return dojo.xhrPost({url:"removeService", handleAs:'json',
 content:{action:"delete", id:id}});
}



var crmServicesStore =

        new dojox.data.PersevereStore
/*      new dojox.data.JsonRestStore */
       
        ({target:"<?php echo $controller; ?>",
                service:crmService,
                queryOptions:{cache:true},
                syncMode:false});

----------------------------------------------------------




and my query is


function updSrvcSt_withChanges( )
{
       
        var foundID=null;
        var srvc_def_id=dijit.byId("ID_srvc_def_id").attr("value");

console.log("srvc def id to search by is: ",srvc_def_id);      

        var thisFunc=this;
        crmServicesStore.fetch(
                {
                        query: {"srvc_def_id":srvc_def_id},
                        queryOptions:{cache:true},
                        scope:thisFunc,
                       
                        onItem: function (item,request)
                                        {
                                                console.log("found for update ",item);
                                                thisFunc.foundID=crmServicesStore.getIdentity(item);
                                        }
                });
       

        console.log("id to update ", foundID);


}








when doing the first search for (second item) here is the print out



srvc def id to search by is:  39
calling query
GET
http://192.168.0.106/codeigniter/index.php/crm/ser...%3D%2739%27)%5D&queryOptions=%5Bobject%20Object%5D
http://192.168.0.106/codeigniter/index.php/crm/services?action=query&query=%5B%3F(%40.srvc_def_id%3D%2739%27)%5D&queryOptions=%5Bobject%20Object%5D
       
200 OK
                100ms bootstrap.js (line 1285)
id to update null
found for update Object srvc_def_id=39 pactorid=i



---------------------  

And I cannot explain  what I am seeing in the above log:

the the value to search by:  39
(it is committed to the store)


then the Store issues query (which I do not want), query returns

then for some reason I see a statement that supposed to happen 'after'
the query
console.log("id to update ", foundID);



and only after that I see that the item was found
because of this statement:  console.log("found for update ",item);



I tried to synch:true or synch:false flag for the store, but it did not
change
the above sequence (thinking that the gets query results asynch may be
causing
the weired sequence).


So I have several problems
1) how to make it so the query to server is not issued if committed item
is in the store
2) is the sequence I am seeing a result of asynch communications?



thank you in advance
--
Vlad P
author of C++  ORM  http://github.com/vladp/CppOrm/tree/master


--
http://www.fastmail.fm - Does exactly what it says on the tin

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

 « Return to Thread: Restful server does not check 'cached' items for query