/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/lru_cache.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""A simple least-recently-used (LRU) cache."""
18
18
 
 
19
from __future__ import absolute_import, division
 
20
 
19
21
from . import (
20
22
    trace,
21
23
    )
 
24
from .sixish import (
 
25
    viewitems,
 
26
    viewkeys,
 
27
    )
22
28
 
23
29
 
24
30
_null_key = object()
25
31
 
26
 
 
27
32
class _LRUNode(object):
28
33
    """This maintains the linked-list which is the lru internals."""
29
34
 
130
135
        :return: An unordered list of keys that are currently cached.
131
136
        """
132
137
        # GZ 2016-06-04: Maybe just make this return the view?
133
 
        return list(self._cache.keys())
 
138
        return list(viewkeys(self._cache))
134
139
 
135
140
    def as_dict(self):
136
141
        """Get a new dict with the same key:value pairs as the cache"""
137
 
        return dict((k, n.value) for k, n in self._cache.items())
 
142
        return dict((k, n.value) for k, n in viewitems(self._cache))
138
143
 
139
144
    def cleanup(self):
140
145
        """Clear the cache until it shrinks to the requested size.
227
232
    defaults to len() if not supplied.
228
233
    """
229
234
 
230
 
    def __init__(self, max_size=1024 * 1024, after_cleanup_size=None,
 
235
    def __init__(self, max_size=1024*1024, after_cleanup_size=None,
231
236
                 compute_size=None):
232
237
        """Create a new LRUSizeCache.
233
238