Toby Bradshaw wrote: > > I wasn't aware SQLAlchemy had any kind of cache built in but I do seem > to be seeing some behaviour that sure looks like it. > > I have an SQA/cherrypy app which shares the DB with another app using > MySQLdb only. Updates in the thirdparty are visible to the thirdparty > immediately. They're not visible to the SQLAlchemy app, even after I > re-execute exactly the same code as loaded them in the first place. > Restarting the SQA app is the only way I've currently seen to make those > changes visible. > > So is there some hidden SQA cache or similar in play here ? It's a PSQL > DB, btw.
there is an identity map within the session. The session documentation describes the behavior and purpose of this cache. It is designed to integrate with the natural isolation of the transaction, in that once the current transaction is committed or rolled back, all elements within the map are expired, and their attributes will be reloaded when next accessed. as long as you are within the current transaction, existing data remains pending within the session, since its impossible to see data from other connections when using standard transaction isolation. methods like expire(), expire_all(), and expunge_all() are provided to have finer grained control over this conversation, but are usually not needed. Note that when using relational databases that support transaction isolation (which is most of them except for MySQL MYISAM tables), one database connection will not see the changes made on another connection until the other connection has committed its transaction, and the local connection has begun a brand new transaction since then. > > -- > t o b e > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---