Rename all the datas to data

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2512 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-02-21 19:21:29 +00:00
parent 82f6f96c2e
commit c283362d05
15 changed files with 92 additions and 85 deletions

View File

@@ -27,40 +27,40 @@ class cachefile
$res = false;
if (file_exists ($fileCache))
{
$datas = file_get_contents ($fileCache);
$datas = unserialize ($datas);
if (($datas["createTime"] + $datas["ttl"]) >= time ())
$data = file_get_contents ($fileCache);
$data = unserialize ($data);
if (($data["createTime"] + $data["ttl"]) >= time ())
{
$res = $datas["data"];
$res = $data["data"];
}
}
if ($res === false)
{
$datas = array ("ttl"=>24*60*60,
"createTime"=>time(),
"data"=>"CACHE-Garbage");
file_put_contents ($fileCache, serialize ($datas));
$data = array ("ttl"=>24*60*60,
"createTime"=>time(),
"data"=>"CACHE-Garbage");
file_put_contents ($fileCache, serialize ($data));
chmod ($fileCache, 0666);
$files = glob ($this->directory."/*", GLOB_NOSORT);
foreach ($files as $fileCache)
{
$datas = file_get_contents ($fileCache);
if ($datas === false)
$data = file_get_contents ($fileCache);
if ($data === false)
{
unlink ($fileCache);
continue;
}
$datas = unserialize ($datas);
if (! isset ($datas["ttl"]) || ! isset ($datas["data"]) ||
! isset ($datas["createTime"]))
$data = unserialize ($data);
if (! isset ($data["ttl"]) || ! isset ($data["data"]) ||
! isset ($data["createTime"]))
{
unlink ($fileCache);
continue;
}
if (($datas["createTime"] + $datas["ttl"]) <= time ())
if (($data["createTime"] + $data["ttl"]) <= time ())
{
unlink ($fileCache);
}
@@ -129,10 +129,10 @@ class cachefile
$this->garbage ();
$fileCache = $this->directory."/".sha1 ($id);
touch ($fileCache.".lock");
$datas = array ("ttl"=>$ttl,
$data = array ("ttl"=>$ttl,
"createTime"=>time(),
"data"=>$data);
file_put_contents ($fileCache, serialize ($datas));
file_put_contents ($fileCache, serialize ($data));
unlink ($fileCache.".lock");
chmod ($fileCache, 0666);
return true;
@@ -174,31 +174,31 @@ class cachefile
usleep (100000);
}
// The lock is pending 10s (stale) : removing it to read the datas quicker
// The lock is pending 10s (stale) : removing it to read the data quicker
// next time
if (file_exists ($fileCache.".lock"))
unlink ($fileCache.".lock");
$datas = file_get_contents ($fileCache);
if ($datas === false)
$data = file_get_contents ($fileCache);
if ($data === false)
{
unlink ($fileCache);
return false;
}
$datas = unserialize ($datas);
if (! isset ($datas["ttl"]) || ! isset ($datas["data"]) ||
! isset ($datas["createTime"]))
$data = unserialize ($data);
if (! isset ($data["ttl"]) || ! isset ($data["data"]) ||
! isset ($data["createTime"]))
{
unlink ($fileCache);
return false;
}
if (($datas["createTime"] + $datas["ttl"]) >= time ())
if (($data["createTime"] + $data["ttl"]) >= time ())
{
if (file_exists ($fileCache.".lock"))
unlink ($fileCache.".lock");
return $datas["data"];
return $data["data"];
}
return false;