Reputation: 399
I use Google Image API get_serving_url to serve images stored in GCS. The get_serving_url is much more expensive in terms of time, comparing to datastore access.
Does the URL ever change? Is it a good idea to get serving url once and store in datastore for further reference?
Here's the time profiling of the request,
Total 999 ms
memcache to get BlobStore key: 1-3 ms
image.GetUrlBase: 903 ms
Part of the code to get serving urls,
class Post(ndb.model):
files = ndb.BlobKeyProperty(repeated=True)
def serving_urls(self):
futures = [get_serving_url_async(blob_key=f, secure_url=True) for f in self.files]
ndb.Future.wait_all(futures)
return [f.get_result() for f in futures]
Thanks in advance.
Upvotes: 4
Views: 422
Reputation: 42038
It should not change, unless you call one of the delete methods (delete_serving_url
or delete_serving_url_async
).
Upvotes: 2