Problem with Python Script in RAM Cache
I wanted to cache a Python script in the ZOPE ram cache manager, but it did not work. I did hear that "RAM cache manager can only cache picklable objects". I do not understand, what that means. I heard that a dictionary would be a "picklable" object. My script returns a sequence (actually the results from a search in the PLONE catalog by the searchresults method). Does that mean, I would have to change my python script so that it would return a dictionary instead of a sequence to be able to be cached by a ram cache manager? Can anybody help me? Thanks Peter Baeuerle
Peter Baeuerle wrote:
I wanted to cache a Python script in the ZOPE ram cache manager, but it did not work. I did hear that "RAM cache manager can only cache picklable objects". I do not understand, what that means. I heard that a dictionary would be a "picklable" object. My script returns a sequence (actually the results from a search in the PLONE catalog by the searchresults method). Does that mean, I would have to change my python script so that it would return a dictionary instead of a sequence to be able to be cached by a ram cache manager? Can anybody help me?
The "sequence of result objects" is a Lazy{Filter,Map,Cat} of catalog brains objects; the brains objects can't be pickled. Have you thought about using a TopicIndex for your complex query? It has better performance than caching, because it computes whether an object matches your query *once* (actually, each time you recatalog the object). Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
Tres Seaver <tseaver <at> zope.com> writes:
The "sequence of result objects" is a Lazy{Filter,Map,Cat} of catalog brains objects; the brains objects can't be pickled.
Have you thought about using a TopicIndex for your complex query? It has better performance than caching, because it computes whether an object matches your query *once* (actually, each time you recatalog the object).
Tres.
Thanks a lot for your rapid response, Tres. I do not yet have experiences with a TopicIndex, but a quick look into the documentation tells me that this seems to be a good solution for my performance problem, indeed. I will try that. Best Regards Peter
participants (2)
-
Peter Baeuerle -
Tres Seaver