Miles Waller wrote:
Now, if I access say, the title attribute of the top folder, the entire folder object is loaded into memory. Am I correct that the subfolder objects (attributes of the folder) are not loaded in at this point, just references to them? Does the same apply to the DateTime objects which are attributes of this folder?

Right. When you load an object, all the attributes are loaded as well. However, if those attributes are subclasses of persistent.Persistent, only references are loaded, not the data itself.

At this point, how many objects would the cache show as needed to be loaded?

1 for your top level object
1 for each non-persistent attribute (and their sub-attributes)

I'm not sure what kind of list the normal folder uses, but I'd guess that this list gets loaded too.

I don't know how the cache handles objects that are not subclassed from persistent.Persistent. That's an interesting side-question.

Assuming that I access the datetime attribute when I load the folder, could I avoid evicting objects from the cache by storing dates as strings rather than DateTimes, so I load one large object rather than two?

DateTime isn't a subclass of persistent.Persistent so I guess it will be loaded anyway if you access the root folder.

Also, am I right that the cache size is determined by total number of objects, rather than by cache size? So loading a large file in, for example, would not evict tons of objects to make room for it.

Yup. The cache is a so-called 'least recently used' (LRU) limited by the amount of objects not their size.

The LRU policy typically does pretty well to avoid unnecessary objects without you having to worry too much. This means that it starts evicting objects that have not been accessed for the longest time.

IIRC the cache cleaning doesn't happen while running a transaction, so that temporarily you can have more active objects than what the cache can hold, but between requests those might get evicted to match the cache's limit.


gocept gmbh & co. kg - forsterstra├če 29 - 06112 halle/saale - germany
www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to