Chromium Code Reviews| Index: client/isolateserver.py |
| diff --git a/client/isolateserver.py b/client/isolateserver.py |
| index 1a679fcfcf1d58f95d3bf03be2e38857be83534c..e3ecfd89401bc0e21ba6e9eda7a0b51afd3a0d15 100755 |
| --- a/client/isolateserver.py |
| +++ b/client/isolateserver.py |
| @@ -1218,6 +1218,9 @@ class LocalCache(object): |
| self._evicted = [] |
| self._linked = [] |
| + def __contains__(self, digest): |
| + raise NotImplementedError() |
| + |
| def __enter__(self): |
| """Context manager interface.""" |
| return self |
| @@ -1302,6 +1305,10 @@ class MemoryCache(LocalCache): |
| self._file_mode_mask = file_mode_mask |
| self._contents = {} |
| + def __contains__(self, digest): |
| + with self._lock: |
| + return digest in self._contents |
| + |
| def cached_set(self): |
| with self._lock: |
| return set(self._contents) |
| @@ -1395,6 +1402,10 @@ class DiskCache(LocalCache): |
| # self._load() calls self._trim() which initializes self._free_disk. |
| self._load() |
| + def __contains__(self, digest): |
| + with self._lock: |
| + return digest in self._lru |
| + |
| def __enter__(self): |
| return self |
| @@ -1523,6 +1534,16 @@ class DiskCache(LocalCache): |
| with self._lock: |
| self._linked.append(self._lru[digest]) |
| + def item_path(self, digest): |
|
M-A Ruel
2016/06/08 20:37:39
It's not needed.
nodir
2016/06/08 22:35:32
Done.
|
| + """Returns a path on disk of the cached item. |
| + |
| + Raises: |
| + CacheMiss if the item is not present in cache. |
| + """ |
| + if digest not in self._lru: |
| + raise CacheMiss(digest) |
| + return self._path(digest) |
| + |
| def _load(self): |
| """Loads state of the cache from json file.""" |
| self._lock.assert_locked() |