62 lines
1.2 KiB
PHP
Executable File
62 lines
1.2 KiB
PHP
Executable File
#!/usr/bin/php
|
|
<?php
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
|
|
use nulib\file\cache\CacheData;
|
|
use nulib\file\cache\CacheFile;
|
|
use nulib\os\sh;
|
|
|
|
//system("rm -f *.cache .*.cache");
|
|
|
|
$what = [
|
|
"null",
|
|
"one",
|
|
"two",
|
|
"three",
|
|
];
|
|
|
|
if (in_array("null", $what)) {
|
|
$null = new CacheFile("null");
|
|
Txx("null=", $null->get());
|
|
}
|
|
|
|
if (in_array("one", $what)) {
|
|
$one = new class("one") extends CacheFile {
|
|
protected function compute() {
|
|
return 1;
|
|
}
|
|
};
|
|
Txx("one=", $one->get());
|
|
}
|
|
|
|
if (in_array("two", $what)) {
|
|
$two = new CacheFile("two", [
|
|
"data" => new CacheData(function () {
|
|
return 2;
|
|
}),
|
|
]);
|
|
Txx("two=", $two->get());
|
|
}
|
|
|
|
if (in_array("three", $what)) {
|
|
$data31 = new CacheData(function () {
|
|
return 31;
|
|
}, "data31name");
|
|
|
|
$data32 = new CacheData(function () {
|
|
return 32;
|
|
});
|
|
|
|
$three = new CacheFile("three", [
|
|
"data" => [
|
|
"data31" => $data31,
|
|
$data31, # name=data31name
|
|
"data32" => $data32,
|
|
$data32, # name=""
|
|
],
|
|
]);
|
|
Txx("three.0=", $three->get("data31"));
|
|
Txx("three.1=", $three->get("data31name"));
|
|
Txx("three.2=", $three->get("data32"));
|
|
Txx("three.3=", $three->get(""));
|
|
} |