Changeset 2752 for trunk/phpgwapi


Ignore:
Timestamp:
05/10/10 16:56:18 (14 years ago)
Author:
amuller
Message:

Ticket #911 - unificação do cache do connector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/js/expressoAjax/expressoAjax.js

    r2676 r2752  
    4242                this.oldY = 0; 
    4343                this.updateVersion = ""; 
    44                 this.cacheRequest = null; 
    45                 this.connectorCache = { 
    46                                 'valid' : [], 
    47                                 'result' : [] 
    48                 }; 
    49                 this.expurgatedCache = new Array(); // Data to purge from cache 
     44                this.cacheRequest = false; 
    5045 
    5146        }; 
     
    297292                        { 
    298293                                handler( expresso.connector.unserialize( data ) ); 
    299                         } 
     294                        }, 
     295                        "cache": expresso.connector.cacheRequest 
    300296                } ); 
     297                this.cacheRequest=false; 
    301298        }; 
    302299        // Cancel Request Connector 
     
    360357        var id = null; 
    361358 
    362         cConnector.prototype.queryConnectorCache = function(url,handler){ 
    363                 if (this.connectorCache.valid[url]) 
    364                 { 
    365                         handler(this.connectorCache.result[url]); 
    366                         return true; 
    367                 } 
    368                 else 
    369                         return false; 
    370         }; 
    371         cConnector.prototype.purgeCache= function(){ 
    372                 if (typeof(preferences) == "undefined" || preferences.use_cache != 'True') 
    373                         return false; 
    374                 var i; 
    375                 for (i=0; i<= this.expurgatedCache.length; i++) 
    376                 { 
    377                         this.connectorCache.valid[this.expurgatedCache[i]] = false; 
    378                         try { 
    379                         delete this.connectorCache.result[this.expurgatedCache[i]]; 
    380                         } 
    381                         catch (e) { }; 
    382                 } 
    383         }; 
    384         cConnector.prototype.cacheNextRequest = function(expiration){ 
    385                 if (typeof(expiration) == 'undefined') 
    386                         expiration=0; 
    387                 this.cacheRequest=expiration; 
    388         }; 
    389  
    390         cConnector.prototype.addToCache = function(id,data){ 
    391                 if (typeof(preferences) == "undefined" || preferences.use_cache != 'True') 
    392                         return false; 
    393                 var func = id.substr(id.lastIndexOf('.')+1); 
    394                 if (func.indexOf('&') > 0) 
    395                         func = func.substr(0,func.indexOf('&')); 
    396                 switch (this.cacheRequest){ 
    397                         // functions that enters in cache and never expires 
    398                         case 0: 
    399                                 data.cacheHit = true; 
    400                                 this.connectorCache.valid[id] = true; 
    401                                 this.connectorCache.result[id] = data; 
    402                                 break; 
    403                         case 1: 
    404                         // function that needs expire 
    405                                 this.connectorCache.valid[id] = true; 
    406                                 this.connectorCache.result[id] = data; 
    407                                 var i = this.expurgatedCache.length; 
    408                                 this.expurgatedCache[i+1] = id; 
    409                                 break; 
    410                         default: 
    411                         // no cache 
    412                                 break; 
    413                 } 
     359        cConnector.prototype.cacheNextRequest = function(){ 
     360                this.cacheRequest=true; 
    414361        }; 
    415362 
     
    430377                } 
    431378                //url = URL_DEFAULT + url; 
    432  
    433                 if (expresso.connector.queryConnectorCache(params?url+"&"+params:url,handler)) 
    434                         return; 
    435  
    436379                if(params) 
    437380                        method = "POST"; 
Note: See TracChangeset for help on using the changeset viewer.