Hi.
David Glick wrote:
> Is there any reason RAM caching using plone.memoize's @ram.cache
> decorator might result in sporadic ConnectionStateErrors? I've been
> experiencing these lately, and they appeared around the same time I
> added memoization, so I'm suspicious. (The methods I'm caching are
> returning a list of catalog brains, FWIW.) If anyone knows a possible
> reason, or can give an explanation of what leads to this error in
> general, I'd be most grateful :)
From the docstring of zope.app.cache.ram:
The idea behind the `RAMCache` is that it should be shared between
threads, so that the same objects are not cached in each thread. This is
achieved by storing the cache data structure itself as a module level
variable (`RAMCache.caches`). This, of course, requires locking on
modifications of that data structure.
Now what does this tell you? Do not store objects in a RAM cache that
belong to a ZODB connection. Any peristent object including wrappers
around those, like catalog brains are a definitive no-no!
Often you won't see the connection state errors at first, since the
objects are all still in the thread local ZODB cache of all threads. Try
lowering your cache-size from the default 5000 to something like 100 and
see what you get. This should warn you a lot earlier (i.e. during
development) when you are doing something wonky ;)
Hanno
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
Plone-developers mailing list
Plone-developers@...
https://lists.sourceforge.net/lists/listinfo/plone-developers