cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / appengine_wrappers.py
blobf477e53eabb34e29a39bd1e6df1b357832486178
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
3 # found in the LICENSE file.
6 # This will attempt to import the actual App Engine modules, and if it fails,
7 # they will be replaced with fake modules. This is useful during testing.
8 try:
9 import google.appengine.api.memcache as memcache
10 except ImportError:
11 class _RPC(object):
12 def __init__(self, result=None):
13 self.result = result
15 def get_result(self):
16 return self.result
18 def wait(self):
19 pass
22 class InMemoryMemcache(object):
23 """An in-memory memcache implementation.
24 """
25 def __init__(self):
26 self._namespaces = {}
28 class Client(object):
29 def set_multi_async(self, mapping, namespace='', time=0):
30 return _RPC(result=dict(
31 (k, memcache.set(k, v, namespace=namespace, time=time))
32 for k, v in mapping.iteritems()))
34 def get_multi_async(self, keys, namespace='', time=0):
35 return _RPC(result=dict(
36 (k, memcache.get(k, namespace=namespace, time=time)) for k in keys))
38 def set(self, key, value, namespace='', time=0):
39 self._GetNamespace(namespace)[key] = value
41 def get(self, key, namespace='', time=0):
42 return self._GetNamespace(namespace).get(key)
44 def delete(self, key, namespace=''):
45 self._GetNamespace(namespace).pop(key, None)
47 def delete_multi(self, keys, namespace=''):
48 for k in keys:
49 self.delete(k, namespace=namespace)
51 def _GetNamespace(self, namespace):
52 if namespace not in self._namespaces:
53 self._namespaces[namespace] = {}
54 return self._namespaces[namespace]
56 def flush_all(self):
57 self._namespaces = {}
58 return False
60 memcache = InMemoryMemcache()