OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from file_system import FileSystem | 5 from file_system import FileSystem |
6 from future import Future | 6 from future import Future |
7 import appengine_memcache as memcache | 7 import appengine_memcache as memcache |
8 | 8 |
9 class MemcacheFileSystem(FileSystem): | 9 class MemcacheFileSystem(FileSystem): |
10 """FileSystem implementation which memcaches the results of Read. | 10 """FileSystem implementation which memcaches the results of Read. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 uncached.append(path) | 50 uncached.append(path) |
51 continue | 51 continue |
52 result[path] = data | 52 result[path] = data |
53 if uncached: | 53 if uncached: |
54 # TODO(cduvall): if there are uncached items we should return an | 54 # TODO(cduvall): if there are uncached items we should return an |
55 # asynchronous future. http://crbug.com/142013 | 55 # asynchronous future. http://crbug.com/142013 |
56 new_items = self._file_system.Read(uncached, binary=binary).Get() | 56 new_items = self._file_system.Read(uncached, binary=binary).Get() |
57 for item in new_items: | 57 for item in new_items: |
58 version = self.Stat(item).version | 58 version = self.Stat(item).version |
59 value = new_items[item] | 59 value = new_items[item] |
| 60 # Cache this file forever. |
60 self._memcache.Set(item, | 61 self._memcache.Set(item, |
61 (value, version), | 62 (value, version), |
62 memcache.MEMCACHE_FILE_SYSTEM_READ) | 63 memcache.MEMCACHE_FILE_SYSTEM_READ, |
| 64 time=0) |
63 result[item] = value | 65 result[item] = value |
64 return Future(value=result) | 66 return Future(value=result) |
OLD | NEW |