| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Defines a dictionary that can evict least recently used items.""" | 5 """Defines a dictionary that can evict least recently used items.""" |
| 6 | 6 |
| 7 import collections | 7 import collections |
| 8 import json | 8 import json |
| 9 | 9 |
| 10 | 10 |
| 11 class LRUDict(object): | 11 class LRUDict(object): |
| 12 """Dictionary that can evict least recently used items. | 12 """Dictionary that can evict least recently used items. |
| 13 | 13 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 Raises KeyError if dict is empty. | 154 Raises KeyError if dict is empty. |
| 155 """ | 155 """ |
| 156 pair = self._items.popitem(last=False) | 156 pair = self._items.popitem(last=False) |
| 157 self._dirty = True | 157 self._dirty = True |
| 158 return pair | 158 return pair |
| 159 | 159 |
| 160 def itervalues(self): | 160 def itervalues(self): |
| 161 """Iterator over stored values in arbitrary order.""" | 161 """Iterator over stored values in arbitrary order.""" |
| 162 return self._items.itervalues() | 162 return self._items.itervalues() |
| OLD | NEW |