@main[]
$sDir[outputs/160]
$iStep(1)
$iSleepTime(3)
$iCacheTime(2)
<table border="1" cellpadding="3">
<tr>
<th>Info</th>
<th>File: 1</th>
<th>File: 2</th>
<th>File: 3</th>
<th>File: 4</th>
</tr>
# row 1
<tr valign="top">
<td>Exec body on 1st step, then just get cached result</td>
<td>
^do[1](3){One}
</td>
<td>
^do[2](3){Two}
</td>
<td>
^do[3](3){Three}
</td>
<td><br /></td>
</tr>
#row 2
<tr valign="top">
<td>Value in cache not expired yet.</td>
<td><br /></td>
<td><br /></td>
<td>
^do[3](3){
^method[]
}{
$exception.handled(1)
^cache(2)
Error while executing body
}
</td>
</tr>
# wait till cache expire
<tr valign="top">
<td>Wait for 3 secs. Cache expired for sure.</td>
<td colspan="3">
^sleep($iSleepTime)
^^sleep($iSleepTime)
</td>
<td><br /></td>
</tr>
# row 3
<tr valign="top">
<td>
1. Body code has an exception but force get cached result<br />
2. Execute body and set ^^cache(0) for prevent cacheing<br />
3. Body code has an exception, execute catch section and set ^^cache(0)
</td>
<td>
^do[1](3){
^method[]
}{
^cache(1)
$exception.handled[cache]
force get cached resuls
}
</td>
<td>
^do[2](3){
Two
^cache(0)
}
</td>
<td>
^do[3](3){
^method[]
}{
$exception.handled(1)
^cache(0)
Catch section results
}
</td>
<td>
^do[4](3){
^method[]
}
</td>
</tr>
</table>
@do[sFile;iSteps;jBody;jExceptionHandler][i;n;bProcessBody;bProcessErrorHandler;iTime;sBody;bError]
^for[i](1;$iSteps){
$iTime[]
$bProcessBody(0)
$bProcessErrorHandler(0)
$nTry(0)
$nCatch(0)
^try{
$sBody[^cache[$sDir/$sFile]($iCacheTime){
^nTry.inc(1)
$jBody ($i)
$bProcessBody(1)
$iTime(^cache[])
}{$bProcessErrorHandler(1)^nCatch.inc(1)$jExceptionHandler}]
^if($bProcessBody){
Executed body, ^^cache[] value ^if(def $iTime){defined}{undefined},
}{
^if($bProcessErrorHandler){
Processing catch section,
}{
Get cached result,
}
}
}{
$bError(1)
$exception.handled(1)
}
^if($bError){
Error. Body executed $nTry times, catch executed $nCatch times.
}{
result: '$sBody'
}
}[<br />]
^iStep.inc(1)
E-mail: