[storm] why weakrefdict for cache?
Bernd Dorn
bernd.dorn at lovelysystems.com
Fri Aug 31 15:00:07 BST 2007
On 31.08.2007, at 14:57, Christopher Armstrong wrote:
> On 8/31/07, Bernd Dorn <bernd.dorn at lovelysystems.com> wrote:
> we use storm with zope (version .10) and discovered that the
> store._cache attribute never caches, because the weakrefs are gone
> immediatly
>
> Your conclusion is incorrect. The cache does work as intended;
> perhaps it is not what you want, though. The cache is there to
> prevent loading objects from the database when they are already in
> memory, and to avoid creating duplicate objects when the same row
> is loaded twice (if a row is retrieved a second time within the
> same transaction, the original object is updated instead of
> creating a new one).
hm dunno if i understood you right ... the point is that i don't want
to retrieve the row again
if i do a store.get(Klass, id) and i don't reference the object
anymore in my code it is gone immediatly
then i do the same get one more time, storm does a select again
i don't understand the use-case for this kind of caching - if i have
to maintain a reference to the object anyways, why do a need the cache?
for example:
we have a request in zope and i want to get a specific storm object i
have to get it via storm.get(...)
in the same request/transaction i do a second get, from another
component of my view and i also have to use storm.get(..) for it
so we end up having up to 30 ident selects to the database for a
single page
i am wondering how this is handled in launchpad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/storm/attachments/20070831/1ad25e5f/attachment.htm
More information about the storm
mailing list