On 03/13/2015 02:10 PM, Jonathan Vanasco wrote:
Ah, so you're not using it to cache the views. No one seems to. Odd.
I think this is because what you call "caching a view" means "caching a response from a view", and this is typically done by caching the rendering of those responses using Varnish/Squid/Apache. That doesn't work real well for views that return very dynamic responses for obvious reasons, so people tend to cache the parts of view computation that are expensive within the view, and use the cached computations to compose the response like you've started doing.
It would of course be possible to build some sort of generic response-caching system based on values present in the request, but what you'll end up with to some extent would be a reimplementation of Squid/Varnish that has access to derived request data and can invalidate cache data more eagerly without any extra HTTP requests, and the benefit of that over a combination of just using Squid/Varnish for not-very-dyamic view responses plus caching derived data *within* some view that is too dynamic to be effectively cached that way is not well understood.
I've migrated my worst views into this pattern with little trouble. The improvements seem great. There were a handful of page elements that were customized based on the request status. In order to handle those, I've been replacing them with placeholders that I regex out. FWIW, I wasn't happy with the SqlAlchemy caching after a while. I opted for a custom dogpile based caching scheme instead. For permissions/groups, I just store a list of ids. For "objects", I convert the columns to dicts and store those, I deserialize into a Pylons style "AttibuteSafe" Dictionary. If I need to handle a relationship, I add in some lambda functions when deserializing. This ended up being a lot faster and with a much smaller memory imprint than caching the SqlAlchemy objects. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com <mailto:pylons-discuss+unsubscr...@googlegroups.com>. To post to this group, send email to pylons-discuss@googlegroups.com <mailto:pylons-discuss@googlegroups.com>. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
-- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.