Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/common/extensions/docs/server2/memcache_file_system.py

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blobstore Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 22 matching lines...) Expand all
33 """ 33 """
34 result = {} 34 result = {}
35 uncached = [] 35 uncached = []
36 for path in paths: 36 for path in paths:
37 cached_result = self._memcache.Get(path, 37 cached_result = self._memcache.Get(path,
38 memcache.MEMCACHE_FILE_SYSTEM_READ) 38 memcache.MEMCACHE_FILE_SYSTEM_READ)
39 if cached_result is None: 39 if cached_result is None:
40 uncached.append(path) 40 uncached.append(path)
41 continue 41 continue
42 data, version = cached_result 42 data, version = cached_result
43 if self.Stat(path).version > version: 43 if self.Stat(path).version != version:
44 self._memcache.Delete(path, memcache.MEMCACHE_FILE_SYSTEM_READ) 44 self._memcache.Delete(path, memcache.MEMCACHE_FILE_SYSTEM_READ)
45 uncached.append(path) 45 uncached.append(path)
46 continue 46 continue
47 result[path] = data 47 result[path] = data
48 new_items = self._file_system.Read(uncached, binary=binary).Get() 48 new_items = self._file_system.Read(uncached, binary=binary).Get()
49 for item in new_items: 49 for item in new_items:
50 version = self.Stat(item).version 50 version = self.Stat(item).version
51 value = new_items[item] 51 value = new_items[item]
52 self._memcache.Set(item, 52 self._memcache.Set(item,
53 (value, version), 53 (value, version),
54 memcache.MEMCACHE_FILE_SYSTEM_READ) 54 memcache.MEMCACHE_FILE_SYSTEM_READ)
55 result[item] = value 55 result[item] = value
56 return Future(value=result) 56 return Future(value=result)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698