[Zope-dev] Re: Z SQL Caching

Dale Hirt dale at sbcltd.com
Mon Sep 26 14:58:15 EDT 2005


Thank you, Martijn.  That makes it very clear.  :)

-----Original Message-----
From: zope-dev-bounces at zope.org [mailto:zope-dev-bounces at zope.org]On
Behalf Of Martijn Pieters
Sent: Monday, September 26, 2005 11:49 AM
To: zope-dev at zope.org
Subject: [Zope-dev] Re: Z SQL Caching


Dale Hirt wrote:
> I have a Z SQL method that is currently returning around 25000 rows. 
> Is there a way to see if it is pulling that data from the cache or is
> doing a refresh?
> 
> Alternatively, and maybe this will answer the first question, the Z SQL
> method is run essentially twice, each time with different parameters. 
> Does it cache each instance, or does it cache the first, then when it's
> run again with different parameters, kill the cache and re-run
> everything?

A ZSQLMethod cache (if configured with a cache duration greater than 0) 
is keyed on the rendered SQL. So, if different parameters lead to a
different SQL query to be sent to the database, then a different key is
used. Caches are kept for the duration of the configured cache duration,
and a given cache key will not influence earlier caches of different
keys.

The SQL is taken quite literally here. If you use the following template: 

  SELECT * FROM foo WHERE <dtml-sqltest bar type="nb">

Then different values for 'bar' will result in different SQL queries and
thus different cache keys. If the same method is called with the same
value for 'bar' within the cache duration, an earlier cached result will
be returned instead of querying the database. Another value for 'bar' in
between those calls will not kill the cache.

Martijn Pieters


_______________________________________________
Zope-Dev maillist  -  Zope-Dev at zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


More information about the Zope-Dev mailing list