-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.php
34 lines (31 loc) · 886 Bytes
/
cache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
function GetCacheFileName( $aFileName )
{
return $aFileName . ".cache";
}
function DumpCacheFile( $aFileName, $aExpire = 3600 )
{
$aCacheFile = GetCacheFileName( $aFileName );
if ( is_file( $aCacheFile ) == True )
{
$aModTime = filemtime( $aCacheFile );
$aCurTime = time();
if ( ( $aCurTime - $aModTime ) > $aExpire )
{
return False;
}
else
{
readfile( $aCacheFile );
return True;
}
}
}
function SaveCacheFile( $aFileName, $aContents )
{
$aCacheFile = GetCacheFileName( $aFileName );
$aFile = fopen( $aCacheFile, "w" );
fwrite( $aFile, $aContents );
fclose( $aFile );
}
?>