/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: 2020-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

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