Hi,
Le 24 avr. 2014 à 19:06, Amine Salmen Rekik <
amine...@gmail.com> a écrit :
> Hello,
>
> Does nagare implement cache feature? Indeed, I have some data retrieved from DB and I need to add them to cache to minimize the requests to DB.
Nagare doesn’t provide a database cache service.
Sometimes when we want to cache some DB requests during the processing of a
HTTP request, we use a function decorator like this:
# ----------
from nagare.local import request
def cached(f):
#
# @cached
# def do_some_db_requests(self, …):
# ...
# return …
#
def _(self):
cache = request.__dict__.setdefault('cache', {})
key = (id(f), id(self))
if key in cache:
r = cache[key]
else:
r = f(self)
cache[key] = r
return r
return _
# ----------
> Thanks
Best regards,
Alain