I never noticed this before today, but apparently RAMCacheManager is
sensitive to whether cached items are acquired from the context or from
the container. (Zope 2.7.3 but afaict it should behave the
same in any recent version).
Is that intended behavior or is this a bug?
Let's say I have a CMF site at http://foo:8080/TheSite.
And a template at /TheSite/portal_skins/custom/template1
which looks in part like like:
Let's say that expensive_script is also in portal_skins/custom
and is associated with a RAMCacheManager.
Let's say that there are *no* request variables configured
for this RAMCacheManager, which would seem to indicate that
we consider all calls to expensive_script equivalent
regardless of the request.
If I visit http://foo:8080/TheSite/page1, which page makes use of this
template, and I reload several times, and look at the RAMCacheManager
statistics view, I see several hits for /TheSite/expensive_script.
Every time I reload, the hit count goes up by one.
So far so good.
But if I then visit another page, http://foo:8080/TheSite/page2,
which uses the same template, I get a miss and the entry
count goes up by one. Reloading then gives me a hit, presumably from
the new entry.
If I browse around the site, the entry count increments for
every new page I hit.
Remember that I have nothing configured in the "REQUEST Variables"
field. So the script should be the same regardless of the
This was puzzling me until, on a hunch, I looked at the
calling template and changed it from this:
And presto, I now get only one entry, and every page on
the site gives me a hit from that one entry.
Is this really intended behavior?
It's not obvious to me from the code why this is happening
(or why it might be desirable). The cache manager stores and looks
up items by their getPhysicalPath(), so I don't see why context vs.
container is relevant. If I'd wanted the URL to be relevant,
I would have put that in the REQUEST Variables configuration.
This could be a performance hit for the unwary ... aside from
all the unnecessary misses, we'd be using RAM on the order
of N * M * S where N is number of cached items and M is number
of pages in the site, and S is average size of return value.
We only should be using N * S.
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -