I have an api call which according to some passed values such as budget and time , returns a list of projects. There will be 100s of projects with there data passed as a json list of objects. I want to cache this result so that I dont have to connect to the backend database every time. I am using flask python for the api dev. Is this kind of code is sufficent taken from Flask Cache doc:
@cache.cached(timeout=50, key_prefix='all_comments')
def get_all_comments():
comments = do_serious_dbio()
return [x.author for x in comments]
cached_comments = get_all_comments()
Or is there another way to do that? My return Json is like:
{ "some_attr" : ,
"another_attr": ,
"list of projects": [ {"name": ,"budget" : } ...]
}