Re: [sqlalchemy] What is a best practice model for cache instances using their detached state?

2017-07-13 Thread Jinghui Niu
Hi Mike, I've read the example of dogpile caching. For my case dogpile.cache seems to be a overkill, could you please provide a thinner example of using Query.merge_result without involving another library? Thanks. On Thu, Jul 13, 2017 at 8:07 PM, Jinghui Niu wrote: >

Re: [sqlalchemy] What is a best practice model for cache instances using their detached state?

2017-07-13 Thread Jinghui Niu
Thanks Mike. Just to clarify, so instead of caching a Query object, I should cache all those queried instance in my `self.search_result_cache`, is this the idea? Is there a way to just relay Query object from one method to another? Which seems a little simpler to me. On Thu, Jul 13, 2017 at 7:20

Re: [sqlalchemy] What is a best practice model for cache instances using their detached state?

2017-07-13 Thread Mike Bayer
you need to use Session.merge and/or Query.merge_result so that a *copy* of the detached object is placed into the Session.In particular, Query.merge_result was created for the use case of caching result sets.

[sqlalchemy] What is a best practice model for cache instances using their detached state?

2017-07-13 Thread Jinghui Niu
I have a web application served by cherrypy (, which is multi-threaded. ) I'm trying to cache a set of rows queried from database using `self.search_result_cache` variable on the GUI_Server object. On my front-end, the web first request `list_entries` to prepare the rows and stores them on