Just wanted to add that there are two things to remember when using memcached.
Your key size is limited to 250 characters so don't try to use the full URI or Query string or your memcached key will be truncated to 250 characters and everything will work, but you will not get what you expect. Also the maximum amount of data you can cache per key is 1 megabyte. On Jul 20, 1:34 pm, Branko Vukelic <[email protected]> wrote: > On Mon, 2009-07-20 at 10:19 -0700, Russ Ryba wrote: > > I used memcached. Check if the results already exist before hitting > > the database. You'll need to generate a unique key before storing > > your results. You can run memcached on the same machine or a separate > > one. Very easy to setup and use. > > > linux prompt> yum -y install python-memcached > > > import memcache > > cache = memcache.Client(['localhost:11211']) > > > def get(self, params): > > query_key = make_key(params) > > records = cache.get(query_key): > > if None == records: > > records = db.query(...) > > cache.set(query_key, records, seconds_to_live) > > # records is now the results of the query from cache or database > > > Quick an dirty answer but that's the general idea. Memcached never > > blocks and returns pretty consistently in milliseconds if it's running > > locally. > > Thanks, I'll try it on. > > -- > Branko > > eml: [email protected] > alt: [email protected] > blg:http://sudologic.blogspot.com/ > img:http://picasaweb.google.com/bg.branko > twt:http://www.twitter.com/foxbunny/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
