Lines Matching refs:Key
43 def Get(key):
47 key: String key value.
50 A value for key.
52 results = MultipartCache.Get(key)
54 results = _GetValueFromDatastore(key)
55 MultipartCache.Set(key, results)
59 def Set(key, value):
63 key: String key value.
66 entity = ndb.Key(MultipartEntity, key).get()
68 entity = MultipartEntity(id=key)
71 MultipartCache.Set(key, value)
74 def Delete(key):
76 ndb.Key(MultipartEntity, key).delete()
77 MultipartCache.Delete(key)
87 def _post_get_hook(cls, key, future): # pylint: disable=unused-argument
93 string_id = entity.key.string_id()
94 part_keys = [ndb.Key(MultipartEntity, string_id, PartEntity, i + 1)
101 def _pre_delete_hook(cls, key):
103 part_keys = PartEntity.query(ancestor=key).fetch(keys_only=True)
116 part = PartEntity(id=i + 1, parent=self.key, value=serialized_parts[i])
131 This entity key has the form:
132 ndb.Key('MultipartEntity', multipart_entity_id, 'PartEntity', part_index)
145 def Get(cls, key):
147 keys = cls._GetCacheKeyList(key)
148 head_key = cls._GetCacheKey(key)
157 for key in keys[:cache_size]:
158 if key not in cache_values:
160 if cache_values[key] is not None:
161 serialized += cache_values[key]
165 def Set(cls, key, value):
173 cached_values[cls._GetCacheKey(key)] = len(serialized_parts)
175 cached_values[cls._GetCacheKey(key, i)] = serialized_parts[i]
179 def Delete(cls, key):
180 """Deletes all cached values for key."""
181 memcache.delete_multi(cls._GetCacheKeyList(key))
184 def _GetCacheKeyList(cls, key):
185 """Gets a list of head cache key and cache key parts."""
186 keys = [cls._GetCacheKey(key, i) for i in xrange(_MAX_NUM_PARTS)]
187 keys.append(cls._GetCacheKey(key))
191 def _GetCacheKey(cls, key, index=None):
192 """Returns either head cache key or cache key part."""
194 return _MULTIPART_ENTITY_MEMCACHE_KEY + '%s.%s' % (key, index)
195 return _MULTIPART_ENTITY_MEMCACHE_KEY + key
198 def _GetValueFromDatastore(key):
199 entity = ndb.Key(MultipartEntity, key).get()