//>>built
define("dstore/Cache","dojo/_base/array dojo/when dojo/_base/declare dojo/_base/lang ./Store ./Memory ./QueryResults".split(" "),function(q,f,h,m,k,r,t){function l(a){return function(){var b=this.inherited(arguments),c=this.cachingCollection||this.cachingStore;b.cachingCollection=c[a].apply(c,arguments);b.isValidFetchCache=!0===this.canCacheQuery||this.canCacheQuery(a,arguments);return b}}function n(a){a.cachingStore||(a.cachingStore=new r);a.cachingStore.Model=a.Model;a.cachingStore.idProperty=a.idProperty}
var p={cachingStore:null,constructor:function(){n(this)},canCacheQuery:function(a,b){return!1},isAvailableInCache:function(){return this.isValidFetchCache&&(this.allLoaded||this.fetchRequest)||this._parent&&this._parent.isAvailableInCache()},fetch:function(){return this._fetch(arguments)},fetchRange:function(){return this._fetch(arguments,!0)},_fetch:function(a,b){var c=this.cachingStore,d=this.cachingCollection||c,e=this,g=this.isAvailableInCache();if(g)return new t(f(g,function(){return e.isAvailableInCache()?
b?d.fetchRange(a[0]):d.fetch():e.inherited(a)}));g=this.fetchRequest=this.inherited(a);f(g,function(a){var d=!b;e.fetchRequest=null;q.forEach(a,function(a){!e.isLoaded||e.isLoaded(a)?c.putSync?c.putSync(a):c.put(a):d=!1});d&&(e.allLoaded=!0);return a});return g},isValidFetchCache:!1,get:function(a,b){var c=this.cachingStore,d=this.getInherited(arguments),e=this;return f(this.fetchRequest,function(){return f(c.get(a),function(g){if(void 0!==g)return g;if(d)return f(d.call(e,a,b),function(b){b&&c.put(b,
{id:a});return b})})})},add:function(a,b){var c=this.cachingStore;return f(this.inherited(arguments),function(d){var e=c.put(a&&"object"===typeof d?d:a,b);return d||e})},put:function(a,b){var c=this.cachingStore;c.put(a,b);return f(this.inherited(arguments)).then(function(d){var e=c.put(a&&"object"===typeof d?d:a,b);return d||e},function(){c.remove(b&&b.id||this.getIdentity(a))})},remove:function(a,b){var c=this.cachingStore;return f(this.inherited(arguments),function(d){return f(c.remove(a,b),function(){return d})})},
evict:function(a){this.allLoaded=!1;return this.cachingStore.remove(a)},invalidate:function(){this.allLoaded=!1},_createSubCollection:function(){var a=this.inherited(arguments);a._parent=this;return a},sort:l("sort"),filter:l("filter"),select:l("select"),_getQuerierFactory:function(a){var b=this.cachingStore;return this.inherited(arguments)||m.hitch(b,b._getQuerierFactory(a))}};k=h(null,p);k.create=function(a,b){a=h.safeMixin(m.delegate(a),p);h.safeMixin(a,b);n(a);return a};return k});
//# sourceMappingURL=Cache.js.map