[TYPO3-core] Bug with the calculation of cache expiry for pages

Jigal van Hemert jigal.van.hemert at typo3.org
Thu May 3 23:01:12 CEST 2012


Hi,

On 3-5-2012 13:18, François Suter wrote:
> Thanks for taking the time. Xavier also posted some comments. I'll take
> a look ASAP, but such calculations always require due care.

Let's discuss the approach for finding the cache lifetime here instead 
of in gerrit reviews.

Meaning of values:
- starttime = 0 : no starttime or -infinite
- starttime > 0 : timestamp
- endtime = 0   : no endtime or +infinite
- endtime > 0 : timestamp

For determining the lifetime we have to find CEs with:
endtime in the future OR no endtime
   or:
endtime > now OR endtime = 0

SELECT * FROM $table WHERE endtime > $now OR endtime = 0
(plus the enableFields we already have)

For all these records we
- ignore the endtime if it is equal to zero (+infinite)
- take the minimum of all the start times which are in the future and 
all end times

SELECT
   MIN(NULLIF(base.endtime,0)),
   MIN(
     CASE WHEN base.starttime <= $now THEN NULL
     ELSE base.starttime
     END
   )
FROM (
   SELECT starttime, endtime
   FROM $table
   WHERE endtime > $now OR endtime = 0
) AS base

(both NULLIF and CASE are ANSI SQL)
(for the subquery the enableFields which were already calculated in the 
current code must be added of course)

I haven't checked the performance of this query, but this can be a start 
to find the correct values.

-- 
Jigal van Hemert
TYPO3 Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-team-core mailing list