Esempio n. 1
0
 def DelMulti(self, keys):
   futures = []
   for key in keys:
     futures.append(db.delete_async(
         PersistentObjectStoreItem.CreateKey(self._namespace, key)))
   # If running the dev server, the futures don't complete until the server is
   # *quitting*. This is annoying. Flush now.
   if IsDevServer():
     [future.wait() for future in futures]
Esempio n. 2
0
 def GetMulti(self, keys):
   db_futures = dict((k, db.get_async(
       PersistentObjectStoreItem.CreateKey(self._namespace, k)))
       for k in keys)
   def resolve():
     return dict((key, future.get_result().GetValue())
                 for key, future in db_futures.iteritems()
                 if future.get_result() is not None)
   return Future(callback=resolve)
Esempio n. 3
0
 def SetMulti(self, mapping):
     futures = []
     for key, value in mapping.items():
         futures.append(
             db.put_async(
                 PersistentObjectStoreItem.CreateItem(
                     self._namespace, key, value)))
     # If running the dev server, the futures don't complete until the server is
     # *quitting*. This is annoying. Flush now.
     if IsDevServer():
         [future.wait() for future in futures]
Esempio n. 4
0
 def SetMulti(self, mapping):
   entities = [PersistentObjectStoreItem.CreateItem(
                   self._namespace, key, value)
               for key, value in mapping.iteritems()]
   # Some entites may be None if they were too large to insert. Skip those.
   rpcs = [db.put_async(entity for entity in entities if entity)]
   # If running the dev server, the futures don't complete until the server is
   # *quitting*. This is annoying. Flush now.
   if IsDevServer():
     [rpc.wait() for rpc in rpcs]
   return All(Future(callback=lambda: rpc.get_result()) for rpc in rpcs)
Esempio n. 5
0
 def SetMulti(self, mapping):
     rpcs = [
         db.put_async(
             PersistentObjectStoreItem.CreateItem(self._namespace, key,
                                                  value))
         for key, value in mapping.iteritems()
     ]
     # If running the dev server, the futures don't complete until the server is
     # *quitting*. This is annoying. Flush now.
     if IsDevServer():
         [rpc.wait() for rpc in rpcs]
     return All(Future(callback=lambda: rpc.get_result()) for rpc in rpcs)
Esempio n. 6
0
 def __init__(self, object_store, keys):
     self._futures = dict((k,
                           db.get_async(
                               PersistentObjectStoreItem.CreateKey(
                                   object_store._namespace, k)))
                          for k in keys)