youre looking for a second-level cache, i agree.  I am extremely  
loathe to call the SA session itself a "cache".   its more analgous  
to the local variable stack in a program function (i.e., its the  
"stuff you are working with at the moment") than anything else.

if you have an application that never writes any data to the DB, you  
can probably use it across processes (although its still probably not  
threadsafe), but any session that intends to be flush()'ed should not  
be used with any kind of cross-scoped/cross-thread/process/shared  
memory scheme.

maybe someday someone can contribute a decent and generic cache  
system to SA (or i would magically have the time to do it)...i know  
TG/Pylons make use of the myghtyutils container system for something  
like this.

On Aug 8, 2006, at 9:58 AM, Alex Greif wrote:

> AFAIK the session is sort of a first-level-cache, that is valid until
> the session is valid.
> A new session builds up a new first-level-cache.
>
> I think what you need is a second level cache that caches globally for
> all sessions.
> Is there something built in into SA, or do you support your own cache,
> like a global dict?
>
> Alex.
>
> On 8/8/06, Julien Cigar <[EMAIL PROTECTED]> wrote:
>> Yep I'm doing something like this too at the moment, but it's a bit a
>> pity to not use the persistent/caching functionality of the  
>> SQLAlchemy
>> sessions and every time reload data (objects) from the database,  
>> even if
>> they haven't changed ...
>>
>> I made some basic tests with memcached and it *seems* to work ...
>>
>> Regards,
>> Julien
>>
>> Alex Greif wrote:
>>> Hi Julien,
>>>
>>> I also use mod_python in the following way:
>>> my handler that is decorated with my decorator: @orm_persistent
>>> that opens a session and eicher in finally or tin the except block
>>> always closes the session, so I can always be sure not to forget to
>>> close a session.
>>> Of cource I can forget the decorator itself ;-)
>>>
>>> For sharing the session object between the apache processes I  
>>> have not
>>> Idea.
>>> But if it is the same thread you could use threadlocal.
>>>
>>> Alex.
>>>
>>> On 8/8/06, Julien Cigar <[EMAIL PROTECTED]> wrote:
>>>> Hello list,
>>>>
>>>> I'm using SQLAlchemy with apache/mod_python (prefork) and a custom
>>>> mod_python handler. I was looking for a solution to share the  
>>>> session
>>>> object between the apache processes.
>>>>
>>>> At the moment I have a session object per process (which work  
>>>> fine), but
>>>> I have to close / reopen the session object for each request  
>>>> which is
>>>> not optimal ... and can cause a lot of problems if I forget to  
>>>> close the
>>>> session at the end of a request, for example if I modify an  
>>>> object in
>>>> the session of a process which is still persistent (cached) in the
>>>> session of another process, etc ...
>>>>
>>>> I plan to use either shared memory (no experience with this at the
>>>> moment) or memcached which look nice. Do you have any suggestion or
>>>> another solution for this ?
>>>>
>>>> Thanks,
>>>> Julien
>>>>
>>>> ------------------------------------------------------------------- 
>>>> ------
>>>>
>>>> Using Tomcat but need to do more? Need to support web services,
>>>> security?
>>>> Get stuff done quickly with pre-integrated technology to make your
>>>> job easier
>>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>>>> Geronimo
>>>> http://sel.as-us.falkag.net/sel? 
>>>> cmd=lnk&kid=120709&bid=263057&dat=121642
>>>> _______________________________________________
>>>> Sqlalchemy-users mailing list
>>>> Sqlalchemy-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>>>>
>>
>>
>
> ---------------------------------------------------------------------- 
> ---
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to