Sets the value for an item. Moves the item up so that it has the highest priority then.
(self, key, value)
| 412 | self._wlock.release() |
| 413 | |
| 414 | def __setitem__(self, key, value): |
| 415 | """Sets the value for an item. Moves the item up so that it |
| 416 | has the highest priority then. |
| 417 | """ |
| 418 | self._wlock.acquire() |
| 419 | try: |
| 420 | if key in self._mapping: |
| 421 | self._remove(key) |
| 422 | elif len(self._mapping) == self.capacity: |
| 423 | del self._mapping[self._popleft()] |
| 424 | self._append(key) |
| 425 | self._mapping[key] = value |
| 426 | finally: |
| 427 | self._wlock.release() |
| 428 | |
| 429 | def __delitem__(self, key): |
| 430 | """Remove an item from the cache dict. |