From 184172a5a6cbcb0b7b66239cc737a10b1599dace Mon Sep 17 00:00:00 2001 From: thisgun Date: Fri, 5 Feb 2021 11:54:14 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BA=90=EC=8B=9C=20=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=ED=8C=8C=EC=9D=BC=EC=97=90=20?= =?UTF-8?q?=EC=9D=BC=EB=B6=80=20hook=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cache.lib.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/cache.lib.php b/lib/cache.lib.php index 5e6c7c6c7..25790dd92 100644 --- a/lib/cache.lib.php +++ b/lib/cache.lib.php @@ -8,6 +8,8 @@ function get_cachemanage_instance(){ static $instance = null; if( ! (defined('G5_USE_CACHE') && G5_USE_CACHE) ) return $instance; + + $instance = run_replace('get_cachemanage_instance', $instance); if( $instance === null ){ $options = array( @@ -48,14 +50,22 @@ function g5_latest_cache_data($bo_table, $cache_list=array(), $find_wr_id=0){ function g5_set_cache($key, $save_data, $ttl = null){ if( $cache = get_cachemanage_instance() ){ - $cache->save($key, $save_data, $ttl); + run_event('g5_set_cache_event', $cache, $key, $save_data, $ttl); + + if( (is_object($cache) && get_class($cache) === 'FileCache') ){ + $cache->save($key, $save_data, $ttl); + } } } function g5_get_cache($key, $expired_time=0){ if( $cache = get_cachemanage_instance() ){ - return $cache->get($key, $expired_time); + if( (is_object($cache) && get_class($cache) === 'FileCache') ){ + return $cache->get($key, $expired_time); + } + + return run_replace('g5_get_cache_replace', false, $cache, $key, $expired_time); } return false; @@ -82,13 +92,21 @@ function g5_delete_all_cache(){ } function g5_delete_cache_by_prefix($key){ - $files = glob(G5_DATA_PATH.'/cache/'.$key.'*'); - foreach( (array) $files as $filename){ - if(empty($filename)) continue; + $cache = get_cachemanage_instance(); + $files = null; - unlink($filename); + if( (is_object($instance) && get_class($instance) === 'FileCache') ) { + $files = glob(G5_DATA_PATH.'/cache/'.$key.'*'); + + foreach( (array) $files as $filename){ + if(empty($filename)) continue; + + unlink($filename); + } } + $files = run_replace('g5_delete_cache_by_prefix', $files, $key); + return ($files) ? true : false; } \ No newline at end of file