On Tue, Mar 13, 2012 at 8:39 AM, Theron Luhn <[email protected]> wrote: > In my application, the first path segment represents a specific object. If > the URL is domain.com/alice/context/view/, traversal will put the > alice object into request. > > The number of users such as alice will be very small relative to pageviews, > so it seems it would be better to keep the objects loaded in memory rather > than pulling one from the disk for every request. What is the best way to > do this? Python discourages globals, and Pyramid discourages thread locals. > Is one of those the best way, or is there something else I'm unaware of?
You can put a cache in the settings dict, or look into memcached or Beaker caching. Settings is the appropriate place for application globals. You can also look at Beaker caching, which has options for expiration and such. If you put a SQLAlchemy ORM object into the cache, call DBSession.expunge() on it first to detach it from the session, Later if you want to use it to modify the database, you'll have to reattach it with DBSession.add() or DBSession.merge() -- see the manual for the difference between the two. -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
