cache-base-min.js revision e4d8ffa5a2367d80114cae95581037557287ee3e
YUI.add("cache-base",function(C){var A=C.Lang,B=function(){B.superclass.constructor.apply(this,arguments);};C.mix(B,{NAME:"cache",ATTRS:{max:{value:0,setter:"_setMax"},size:{readOnly:true,getter:"_getSize"},uniqueKeys:{value:false,validator:function(D){return(A.isBoolean(D));}},entries:{readOnly:true,getter:"_getEntries"}}});C.extend(B,C.Base,{_entries:null,initializer:function(D){this.publish("add",{defaultFn:this._defAddFn});this.publish("flush",{defaultFn:this._defFlushFn});this._entries=[];},destructor:function(){this._entries=null;},_setMax:function(E){var D=this._entries;if(E>0){if(D){while(D.length>E){D.shift();}}}else{E=0;this._entries=[];}return E;},_getSize:function(){return this._entries.length;},_getEntries:function(){return this._entries;},_defAddFn:function(G){var E=this._entries,D=this.get("max"),F=G.entry;if(this.get("uniqueKeys")&&(this.retrieve(G.entry.request))){E.shift();}while(D&&E.length>=D){E.shift();}E[E.length]=F;},_defFlushFn:function(D){this._entries=[];},_isMatch:function(E,D){return(E===D.request);},add:function(E,D){if(this.get("entries")&&((this.get("max")===null)||this.get("max")>0)&&(A.isValue(E)||A.isNull(E)||A.isUndefined(E))){this.fire("add",{entry:{request:E,response:D}});}else{}},flush:function(){this.fire("flush");},retrieve:function(H){var D=this._entries,G=D.length,F=null,E=G-1;if((G>0)&&((this.get("max")===null)||(this.get("max")>0))){this.fire("request",{request:H});for(;E>=0;E--){F=D[E];if(this._isMatch(H,F)){this.fire("retrieve",{entry:F});if(E<G-1){D.splice(E,1);D[D.length]=F;}return F;}}}return null;}});C.Cache=B;},"@VERSION@",{requires:["base"]});