4

I have an app which saves last search of user via Cookies, then I have a search view that I'd like to cache.

I cannot memoize the query result as there are some weird objects like db.session which cannot be understood by pickle, which Flask-Cache uses.

I cannot cache the rendered view because it could happen that User A comes with Cookie A and User B with Cookie B but because the view is saved with the search of User A, User B receives a view with the search parameters of User A.

Is there a way to cache the result of a SQL-Alchemy Paginated Result in Flask-Cache? Or to cache a view taking into account the cookies?

The following doesn't work:

@cache.memoize(60 * 60)
def find_job_per_id(id):
    return Job.query.filter(Job.id == id).first()
davidism
  • 121,510
  • 29
  • 395
  • 339
Laurent Meyer
  • 2,766
  • 3
  • 33
  • 57

0 Answers0