Hi,
I have a particular query that takes on the order of .3 seconds,
selecting roughly 1000 records. This query will be called multiple
times during the life of the application. It looks like:
records = MyTable.mapper.select()
What I've done is put this query into a function that uses
memoization, so:
__allrecords = [] # global
def getAll():
global __allrecords
if not __allrecords:
__allrecords = MyTable.mapper.select()
return __allrecords
This is fine and great, except if the results of the actual SELECT
query change, if a record is added or deleted for example. If I can
ensure that all interaction with the table itself go through my
MyTable class, then I can add some smarts to that class that know
when to update the global list when records change. However, it is
possible that records will change outside of SA (another client
poking at the db through `psql`, for example).
Is there something more clever I can do to know when to re-run the
query and re-set the global? Can I get a "last-modified" timestamp
from the DB, can SA do this automatically?
TIA,
--
Dimi Shahbaz, Software Engineer Specialist
California PASS Program
www.cyberhigh.fcoe.k12.ca.us
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users