Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define("karma/kernel/factory/store/Cache", ["dojo"], function(dojo) {
- dojo.getObject("karma.kernel.factory.store",true);
- karma.kernel.factory.store.Cache = function(cacheStore,cachingStore,options){
- options = options || {};
- return dojo.delegate(cacheStore, {
- cachingStore:cachingStore,
- query: function(query, directives){
- //HACK: adding a ? on the fly because RQL doesn't like the query to begin with a ?
- // and the underlying JRS will not add it unless the query is an object
- directives = directives || {};
- if (!directives.queryCache) { //only add the ? if we are going to do an actual post to the server
- if (!(typeof query === 'undefined' || dojo.isObject(query))) {
- query = (query.charAt(0) == "?") ? query : "?" + query;
- }
- }
- return (!directives.queryCache)?cacheStore.query(query, directives):cachingStore.query(query, directives);
- },
- putCache: function(object, directives){
- // first remove from the cache
- cachingStore.remove((directives && directives.id) || this.getIdentity(object));
- // now put result in cache
- return cachingStore.put(object, directives);
- },
- removeCache: function(id, directives){
- return cachingStore.remove(id, directives);
- }
- });
- };
- return karma.kernel.factory.store.Cache;
- });
Add Comment
Please, Sign In to add comment