|
|
| version 1.1, 2008/05/14 09:24:17 | version 1.4, 2017/12/07 00:55:12 |
|---|---|
| Line 1 | Line 1 |
| @main[][sDir;sName;tList;hf;i] | @main[][sDir;sName;hf;hf2;tList;i;k;v;iSizeBefore;iSizeAfter] |
| $sDir[174] | $sDir[174] |
| $sName[data] | $sName[data] |
| # remove previous files first | # remove previous files first |
| $tList[^file:list[$sDir]] | $tList[^file:list[$sDir]] |
| ^tList.menu{ | ^tList.menu{ |
| ^file:delete[$sDir/$tList.name] | ^file:delete[$sDir/$tList.name] |
| } | } |
| # open hashfile | |
| # open hashfiles | |
| $hf[^hashfile::open[$sDir/$sName]] | $hf[^hashfile::open[$sDir/$sName]] |
| $hf2[^hashfile::open[$sDir/${sName}2]] | |
| ^try-catch{ ^hashfile::open[$sDir/$sName] } | |
| # check hashfile files -- it mustn't exist because of delayed opened | # check hashfile files -- it mustn't exist because of delayed opened |
| ^checkFiles[$sDir;$sName] | ^checkFiles[$sDir;$sName] |
| <hr /> | ^checkFiles[$sDir;${sName}2] |
| # $hf2 for checking .cleanup[] | |
| ^fill[$hf2] | |
| $iSizeBefore(^getFileSize[$sDir;${sName}2]) | |
| $hf.temp[temp] | |
| ^hf.clear[] | |
| # add item with key '0' for 2 sec | # add item with key '0' for 2 sec |
| $hf.0[ | $hf.0[ |
| Line 21 $hf.0[ | Line 34 $hf.0[ |
| $.expires(2/24/60/60) | $.expires(2/24/60/60) |
| ] | ] |
| # add more items to hashfile | # add more items to hf |
| ^for[i](1;9){ | ^for[i](1;9){ |
| $hf.[$i][=$i=] | $hf.[$i][=$i=] |
| } | } |
| ^json:string[^hf.hash[]] | |
| <hr /> | |
| ^checkFiles[$sDir;$sName] | ^checkFiles[$sDir;$sName] |
| ^checkFiles[$sDir;${sName}2] | |
| ^$hf.0: '$hf.0'<br /> | |
| <hr /> | <hr /> |
| # wait 2 secs till item with key '0' expired | ^$hf.0: '$hf.0'<br /> |
| # wait till some items expire | |
| ^sleep(3) | ^sleep(3) |
| <hr /> | |
| # $hf2 for checking .cleanup[]: add many items, read _file_ size, wait till items expire, .cleanup[], | |
| # add the same number of items, read file size again and compare sizes. | |
| # second file size must not be higher because of space used with expired items must be reused | |
| ^hf2.cleanup[] | |
| #^hf2.foreach[;]{} | |
| ^fill[$hf2] | |
| $iSizeAfter(^getFileSize[$sDir;${sName}2]) | |
| ^if($iSizeAfter > $iSizeBefore){file size increased}{file size wasn't increased} | |
| <hr /> | |
| ^$hf.0: '$hf.0'<br /> | ^$hf.0: '$hf.0'<br /> |
| # release before .foreach | |
| ^hf.release[] | |
| <hr /> | <hr /> |
| keys: ^hf.foreach[k;]{$k}[, ] | keys: ^hf.foreach[k;]{$k}[, ] |
| # release before .delete | |
| ^hf.release[] | |
| ^hf.delete[1] | |
| <hr /> | <hr /> |
| ^hf.delete[1] | |
| ^hf.foreach[k;v]{^$hf.${k}: '$v'<br />} | ^hf.foreach[k;v]{^$hf.${k}: '$v'<br />} |
| ^hf.delete[2] | |
| <hr /> | <hr /> |
| ^hf.delete[2] | |
| $s[^hf.foreach[k;v]{^$hf.${k}: '$v'}[<br />]] | $s[^hf.foreach[k;v]{^$hf.${k}: '$v'}[<br />]] |
| $s<br /> | $s<br /> |
| # checking for cleanup (just calls: we can't check internals) | |
| ^hf.cleanup[] | |
| <hr /> | <hr /> |
| # delete hashfile | # delete hashfile |
| ^hf.delete[] | ^hf.delete[] |
| # files mustn't exist after .delete[] | # files mustn't exist after .delete[] |
| ^checkFiles[$sDir;$sName] | ^checkFiles[$sDir;$sName] |
| # try to read not existing hashfile (it must auto opened) | |
| <hr /> | <hr /> |
| # trying to read not existing hashfile (it must auto opened) | |
| ^hf.foreach[k;v]{^$hf.${k}: '$v'<br />} | ^hf.foreach[k;v]{^$hf.${k}: '$v'<br />} |
| # files must exist now | # files must exist now |
| ^checkFiles[$sDir;$sName] | ^checkFiles[$sDir;$sName] |
| @checkFiles[sDir;sName] | @checkFiles[sDir;sName] |
| ^checkFile[$sDir/${sName}.dir] | ^checkFile[$sDir/${sName}.dir] |
| ^checkFile[$sDir/${sName}.pag] | ^checkFile[$sDir/${sName}.pag] |
| @checkFile[sFileName] | @checkFile[sFileName] |
| $sFileName -- ^if(-f $sFileName){exist}{not exist}<br /> | $sFileName -- ^if(-f $sFileName){exist}{not exist}<br /> |
| @getFileSize[sDir;sName][fStat] | |
| $fStat[^file::stat[$sDir/${sName}.pag]] | |
| $result($fStat.size) | |
| @fill[hf][iCount;i] | |
| $iCount(150) | |
| ^for[i](0;$iCount){ | |
| $hf.[^math:uuid[]][ | |
| $.value[^math:uuid[]] | |
| $.expires(2/24/60/60) | |
| ] | |
| } | |
| ^hf.release[] |