Guest User

Untitled

a guest
Apr 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define("karma/kernel/factory/store/Cache", ["dojo"], function(dojo) {
  2.     dojo.getObject("karma.kernel.factory.store",true);
  3.     karma.kernel.factory.store.Cache = function(cacheStore,cachingStore,options){
  4.         options = options || {};
  5.         return dojo.delegate(cacheStore, {
  6.             cachingStore:cachingStore,
  7.             query: function(query, directives){
  8.            
  9.                 //HACK: adding a ? on the fly because RQL doesn't like the query to begin with a ?
  10.                 // and the underlying JRS will not add it unless the query is an object
  11.                 directives = directives || {};
  12.                 if (!directives.queryCache) { //only add the ? if we are going to do an actual post to the server              
  13.                     if (!(typeof query === 'undefined' || dojo.isObject(query))) {
  14.                         query = (query.charAt(0) == "?") ? query : "?" + query;
  15.                     }
  16.                 }
  17.                
  18.                 return (!directives.queryCache)?cacheStore.query(query, directives):cachingStore.query(query, directives);
  19.             },
  20.             putCache: function(object, directives){
  21.                
  22.                 // first remove from the cache
  23.                 cachingStore.remove((directives && directives.id) || this.getIdentity(object));
  24.                
  25.                 // now put result in cache
  26.                 return cachingStore.put(object, directives);
  27.             },
  28.             removeCache: function(id, directives){
  29.  
  30.                 return cachingStore.remove(id, directives);
  31.             }
  32.         });
  33.     };
  34.     return karma.kernel.factory.store.Cache;
  35. });
Add Comment
Please, Sign In to add comment