| 46 | | while True: |
|---|
| 47 | | expirationTime, objSize, objKey = self.expirationQueue.get(block=True, timeout=None) |
|---|
| 48 | | # expireCache runs in a separate thread which the servers are |
|---|
| 49 | | # not aware of. It's possible that "time" will be set to None |
|---|
| 50 | | # arbitrarily, so we check "while time" to avoid exceptions. |
|---|
| 51 | | # See tickets #99 and #180 for more information. |
|---|
| 52 | | while time and (time.time() < expirationTime): |
|---|
| 53 | | time.sleep(0.1) |
|---|
| 54 | | try: |
|---|
| 55 | | del self.cache[objKey] |
|---|
| 56 | | self.totExpires += 1 |
|---|
| 57 | | self.cursize -= objSize |
|---|
| 58 | | except KeyError: |
|---|
| 59 | | # the key may have been deleted elsewhere |
|---|
| 60 | | pass |
|---|
| | 33 | # expireCache runs in a separate thread which the servers are |
|---|
| | 34 | # not aware of. It's possible that "time" will be set to None |
|---|
| | 35 | # arbitrarily, so we check "while time" to avoid exceptions. |
|---|
| | 36 | # See tickets #99 and #180 for more information. |
|---|
| | 37 | while time: |
|---|
| | 38 | now = time.time() |
|---|
| | 39 | for expirationTime, objects in self.expirations: |
|---|
| | 40 | if expirationTime <= now: |
|---|
| | 41 | for objSize, objKey in objects: |
|---|
| | 42 | try: |
|---|
| | 43 | del self.cache[objKey] |
|---|
| | 44 | self.totExpires += 1 |
|---|
| | 45 | self.cursize -= objSize |
|---|
| | 46 | except KeyError: |
|---|
| | 47 | # the key may have been deleted elsewhere |
|---|
| | 48 | pass |
|---|
| | 49 | time.sleep(0.1) |
|---|
| 77 | | # checks if there's space for the object |
|---|
| 78 | | if ((objSize < self.maxobjsize) and |
|---|
| 79 | | (totalSize < self.maxsize) and |
|---|
| 80 | | (len(self.cache) < self.maxobjects)): |
|---|
| 81 | | # add to the expirationQueue & cache |
|---|
| 82 | | try: |
|---|
| 83 | | expirationTime = time.time() + cherrypy.request.config.get("tools.caching.delay", 600) |
|---|
| | 64 | if len(self.cache) < conf("tools.caching.maxobjects", 1000): |
|---|
| | 65 | # Size check no longer includes header length |
|---|
| | 66 | objSize = len(obj[2]) |
|---|
| | 67 | maxobjsize = conf("tools.caching.maxobjsize", 100000) |
|---|
| | 68 | |
|---|
| | 69 | totalSize = self.cursize + objSize |
|---|
| | 70 | maxsize = conf("tools.caching.maxsize", 10000000) |
|---|
| | 71 | |
|---|
| | 72 | # checks if there's space for the object |
|---|
| | 73 | if (objSize < maxobjsize and totalSize < maxsize): |
|---|
| | 74 | # add to the expirations list and cache |
|---|
| | 75 | expirationTime = time.time() + conf("tools.caching.delay", 600) |
|---|