Forum Discussion
Deb_Allen_18
Feb 06, 2008Historic F5 Account
To answer your question, I've used the clock to trigger periodic housekeeping in other circumstances, something like this:
when RULE_INIT {
set ::pdfappmaxRate 10 ;set later per user from class
set ::pdfappwindowSecs 10 ;global
init array if non-existent
array set ::pdfHistory { }
wipe array if already existent
array unset ::pdfHistory
set ::housekeeping_clock [clock seconds]
set ::housekeeping_interval 900
}
when HTTP_REQUEST {
if { [clock seconds] > [expr {$::housekeeping_clock + $::housekeeping_interval}] }{
wipe array if already existent
array unset ::pdfHistory
}
...
}
However, this code block should reap the old entries from the array upon every request:
count GETs within the window, delete those that are older
foreach { requestID requestTime } [array get ::pdfHistory ${pdfapp_session}*] {
count pdf downloadss with start time > $pdfappwindowStart, delete the rest
if { $requestTime > $pdfappwindowStart } {
incr pdfCount 1
} else {
unset ::pdfHistory($requestID)
}
}
Not sure why it isn't doing so. Before I added another periodic housekeeping function, esp one that's indiscriminate like that above, I'd try to figure out why this isn't working. I'd start by adding some logging here to see if anything is matching the delete condition.
HTH
/deb