text: define("Lib/Cache/Cache",["Core/core-extend","Env/Env","Core/Deferred"],function(e,r,i){function t(){return true}var a={},n=e({},{$protected:{_cache:{},_options:{name:"",factory:null,expire:-1}},$constructor:function(){if(-1===this._options.expire)this._isItemValid=t},getItem:function(e){return this._getItemData(this._getItem.apply(this,arguments))},purge:function(e){if(e)delete this._cache[e];else this._cache={}},destroy:function(){this.purge(),delete a[this._options.name]},_getItemLow:function(e){return this._cache[e]},_getItem:function(e){var t=this._getItemLow(e);if(t)if(this._isItemValid(t))return t;else return this._mkItem.apply(this,arguments);else return this._mkItem.apply(this,arguments)},_getItemData:function(e){return e.deferred&&e.deferred.createDependent()||(new i).callback(e.data)},_isItemValid:function(e){return!e.dirty&&("data"in e||"deferred"in e)&&this._options.expire>0&&+new Date-e.created<=this._options.expire},_mkItem:function(e){var t=new i,r={created:+new Date,deferred:t},n=this;return this._cache[e]=r,this._options.factory.apply(null,arguments).addBoth(function(e){if(e instanceof Error)if(r.dirty=true,"data"in e)e=e.data;return n._setItemResult(r,e),e}),r},_setItemResult:function(e,t){var r=e.deferred;return e.data=t,delete e.deferred,r.callback(t),t}});function c(e,t){return e?new e(t):r.IoC.resolve("ICache",t)}return r.IoC.bind("ICache","Cache"),n.getByName=function(e,t,r,n){return a[e]=a[e]||c(n,{name:e,expire:t,factory:r})},n});