~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lru_cache.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-20 15:02:05 UTC
  • mto: (3735.2.161 brisbane-core)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090320150205-kcmh70biyo76p0kn
Some testing to see if we can decrease the peak memory consumption a bit.
It looks like we can, just need some more perf, etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
    def clear(self):
152
152
        """Clear out all of the cache."""
153
153
        # Clean up in LRU order
154
 
        while self._cache:
155
 
            self._remove_lru()
 
154
        for key in self._cache.keys():
 
155
            self._remove(key)
 
156
        assert not self._cache
 
157
        assert not self._cleanup
 
158
        self._queue = deque()
 
159
        self._refcount = {}
156
160
 
157
161
    def resize(self, max_cache, after_cleanup_count=None):
158
162
        """Change the number of entries that will be cached."""
247
251
        val = LRUCache._remove(self, key)
248
252
        self._value_size -= self._compute_size(val)
249
253
 
 
254
    def clear(self):
 
255
        LRUCache.clear(self)
 
256
        self._value_size = 0
 
257
 
250
258
    def resize(self, max_size, after_cleanup_size=None):
251
259
        """Change the number of bytes that will be cached."""
252
260
        self._update_max_size(max_size, after_cleanup_size=after_cleanup_size)