Created
January 8, 2024 18:01
-
-
Save HanbitGaram/56809a9d0c174608a9deb6f4dac4a92e to your computer and use it in GitHub Desktop.
그누보드용 간이 캐싱 도구
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 | |
function get_hanbit_cache(string $cacheName, int $cacheTime=5){ | |
$cacheName = preg_replace("#[^a-zA-Z0-9\-\_]#", "", $cacheName); | |
$file = G5_PATH.'/data/cache/hanbit-cache-'.$cacheName.'-final.bin'; | |
if(!is_file($file)) return false; | |
$currentTime = time(); | |
$fileTime = filemtime($file); | |
if($currentTime - $fileTime >= $cacheTime) return false; | |
return unserialize(file_get_contents($file)); | |
} | |
function set_hanbit_cache(string $cacheName, $cacheValue){ | |
$cacheName = preg_replace("#[^a-zA-Z0-9\-\_]#", "", $cacheName); | |
$file = G5_PATH.'/data/cache/hanbit-cache-'.$cacheName.'-final.bin'; | |
$cacheValue = serialize($cacheValue); | |
file_put_contents($file, $cacheValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment