def Run(self, limit, offset): opts = self._gae_query._Query__query_options if opts.keys_only or opts.projection: return self._gae_query.Run(limit=limit, offset=offset) ret = caching.get_from_cache(self._identifier) if ret is not None and not utils.entity_matches_query( ret, self._gae_query): ret = None if ret is None: # We do a fast keys_only query to get the result keys_query = Query(self._gae_query._Query__kind, keys_only=True) keys_query.update(self._gae_query) keys = keys_query.Run(limit=limit, offset=offset) # Do a consistent get so we don't cache stale data, and recheck the result matches the query ret = [ x for x in datastore.Get(keys) if utils.entity_matches_query(x, self._gae_query) ] if len(ret) == 1: caching.add_entity_to_cache( self._model, ret[0], caching.CachingSituation.DATASTORE_GET) return iter(ret) return iter([ret])
def Run(self, limit, offset): opts = self._gae_query._Query__query_options if opts.keys_only or opts.projection: return self._gae_query.Run(limit=limit, offset=offset) ret = caching.get_from_cache(self._identifier, self._namespace) if ret is not None and not utils.entity_matches_query(ret, self._gae_query): ret = None if ret is None: # We do a fast keys_only query to get the result keys_query = Query(self._gae_query._Query__kind, keys_only=True, namespace=self._namespace) keys_query.update(self._gae_query) keys = keys_query.Run(limit=limit, offset=offset) # Do a consistent get so we don't cache stale data, and recheck the result matches the query ret = [x for x in datastore.Get(keys) if x and utils.entity_matches_query(x, self._gae_query)] if len(ret) == 1: caching.add_entities_to_cache( self._model, [ret[0]], caching.CachingSituation.DATASTORE_GET, self._namespace, ) return iter(ret) return iter([ret])
def Count(self, limit, offset): ret = caching.get_from_cache(self._identifier) if ret is not None and not utils.entity_matches_query(ret, self._gae_query): ret = None if ret is None: return self._gae_query.Count(limit=limit, offset=offset) return 1
def Count(self, limit, offset): ret = caching.get_from_cache(self._identifier) if ret is not None and not utils.entity_matches_query( ret, self._gae_query): ret = None if ret is None: return self._gae_query.Count(limit=limit, offset=offset) return 1
def Run(self, limit, offset): opts = self._gae_query._Query__query_options if opts.keys_only or opts.projection: return self._gae_query.Run(limit=limit, offset=offset) ret = caching.get_from_cache(self._identifier) if ret is None: ret = [ x for x in self._gae_query.Run(limit=limit, offset=offset) ] if len(ret) == 1: caching.add_entity_to_cache(self._model, ret[0], caching.CachingSituation.DATASTORE_GET) return iter(ret) return iter([ ret ])
def Count(self, limit, offset): ret = caching.get_from_cache(self._identifier) if ret is None: return self._gae_query.Count(limit=limit, offset=offset) return 1