~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lru_cache.py

  • Committer: John Arbash Meinel
  • Date: 2007-11-16 23:53:17 UTC
  • mto: This revision was merged to the branch mainline in revision 3027.
  • Revision ID: john@arbash-meinel.com-20071116235317-uymqhilped1rloqy
Implement LRUCache.get() which acts like dict.get()
so that we can return a default if the key isn't present.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
            # Trigger the cleanup
70
70
            self.cleanup()
71
71
 
 
72
    def get(self, key, default=None):
 
73
        if key in self._cache:
 
74
            return self[key]
 
75
        return default
 
76
 
72
77
    def cleanup(self):
73
78
        """Clear the cache until it shrinks to the requested size.
74
79