Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1184

Show
Ignore:
Timestamp:
07/05/06 13:25:43
Author:
fumanchu
Message:

Speedup of cache tool by caching the object only, not expirationTime or lastModified.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/caching.py

    r1163 r1184  
    6161     
    6262    def get(self): 
    63         """ 
    64         If the content is in the cache, returns a tuple containing the  
    65         expiration time, the lastModified response header and the object  
    66         (rendered as a string); returns None if the key is not found. 
    67         """ 
     63        """Return the object if in the cache, else None.""" 
    6864        self.totGets += 1 
    6965        cacheItem = self.cache.get(self.key, None) 
     
    7470            return None 
    7571     
    76     def put(self, lastModified, obj): 
     72    def put(self, obj): 
    7773        # Size check no longer includes header length 
    7874        objSize = len(obj[2]) 
     
    8884                objKey = self.key 
    8985                self.expirationQueue.put((expirationTime, objSize, objKey)) 
    90                 self.cache[objKey] = (expirationTime, lastModified, obj) 
     86                self.cache[objKey] = obj 
    9187                self.totPuts += 1 
    9288                self.cursize += objSize 
     
    113109     
    114110    if c: 
    115         expirationTime, lastModified, obj = cacheData 
    116         s, cherrypy.response.header_list, b = obj 
     111        s, cherrypy.response.header_list, b = cacheData 
    117112        try: 
    118113            cptools.validate_since() 
     
    141136        if response.headers.get('Pragma', None) != 'no-cache': 
    142137            # save the cache data 
    143             lastModified = response.headers.get('Last-Modified', None) 
    144138            body = ''.join([chunk for chunk in output]) 
    145             cherrypy._cache.put(lastModified, 
    146                                 (response.status, response.header_list, body)) 
     139            cherrypy._cache.put((response.status, response.header_list, body)) 
    147140    response.body = tee(response.body) 
    148141 

Hosted by WebFaction

Log in as guest/cpguest to create tickets