equal
deleted
inserted
replaced
538 |
538 |
539 The head node is the newest entry in the cache. If the cache is full, |
539 The head node is the newest entry in the cache. If the cache is full, |
540 we recycle head.prev and make it the new head. Cache accesses result in |
540 we recycle head.prev and make it the new head. Cache accesses result in |
541 the node being moved to before the existing head and being marked as the |
541 the node being moved to before the existing head and being marked as the |
542 new head node. |
542 new head node. |
543 |
|
544 NOTE: construction of this class doesn't scale well if the cache size |
|
545 is in the thousands. Avoid creating hundreds or thousands of instances |
|
546 with large capacities. |
|
547 """ |
543 """ |
548 def __init__(self, max): |
544 def __init__(self, max): |
549 self._cache = {} |
545 self._cache = {} |
550 |
546 |
551 self._head = head = _lrucachenode() |
547 self._head = head = _lrucachenode() |