11 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Caching
FromSent OnAttachments
Anton V. Belyaev19 Dec 2007 14:19 
Michael Bayer19 Dec 2007 18:41 
Anton V. Belyaev20 Dec 2007 02:06 
Michael Bayer20 Dec 2007 07:51 
Anton V. Belyaev20 Dec 2007 10:03 
Michael Bayer20 Dec 2007 12:57 
Michael Bayer20 Dec 2007 23:15 
Anton V. Belyaev21 Dec 2007 12:53 
Michael Bayer21 Dec 2007 13:42.py
Michael Bayer21 Dec 2007 13:58.py
Anton V. Belyaev22 Dec 2007 14:25 
Subject:[sqlalchemy] Re: Caching
From:Michael Bayer (mike@zzzcomputing.com)
Date:12/19/2007 06:41:11 PM
List:com.googlegroups.sqlalchemy

On Dec 19, 2007, at 5:19 PM, Anton V. Belyaev wrote:

Hello,

Several people already wrote something about memcached + SqlAlchemy.

Remember, Mike Nelson wrote a mapper extention, it is available at: http://www.ajaxlive.com/repo/mcmapper.py http://www.ajaxlive.com/repo/mcache.py

I've rewritten it a bit to fit 0.4 release of SA.

Any response and comments are welcome, since I am not sure I am doing right things in the code :) I dont like that dirty tricks with deleting _state, etc. Maybe it could be done better?

what happens if you just leave "_state" alone ? there shouldnt be any need to mess with _state (nor _entity_name). the only attribute worth deleting for the cache operation is "_sa_session_id" so that the instance isnt associated with any particular session when it gets cached. Id also consider using session.merge(dont_load=True) which is designed for use with caches (and also watch out for that log.debug(), debug() calls using the standard logging module are notoriously slow).

It has some problems with deferred fetch on inherited mapper because of some issues of SA (I've found them in Trac).

the only trac ticket for this is #490, which with our current extension architecture is pretty easy to fix so its resolved in 3967 - MapperExtensions are now fully inherited. If you apply the same MapperExtension explicitly to a base mapper and a subclass mapper, using the same ME instance will have the effect of it being applied only once (and using two different ME instances will have the effect of both being applied to the subclass separately).