cachetools
tried and work fine in bottle, and another web framework (blacksheep, fastapi, flask, klein, quart, responder, sanic, starlette) with pydal as backend, should be fine with py4web too
e.g.
from cachetools import TTLCache
cache = TTLCache(maxsize = 99, ttl = 60)
rows = db(query).select(cache = cache, cacheable = True)
Please be aware that all these classes are not thread-safe. Access to a shared cache from multiple threads must be properly synchronized, e.g. by using one of the memoizing decorators with a suitable lock object.
ref
question
- any idea how to make cachetools.TTLCache() more safe thread ?
- any example for use functools.lru_cache in py4web ?
n.b.
pydal dont provide cache in their own package
thanks n best regards,
stifan