Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function apcu_check() { if (!self::apcu_enabled()) throw new Exception('APCU module not enabled'); }
- public static function apcu_enabled() { return function_exists('apcu_enabled') && apcu_enabled(); }
- public static function apcu_get($uniqueid) { return \apcu_fetch($uniqueid); }
- public static function apcu_set($uniqueid, $data) { return \apcu_store($uniqueid, $data); }
- public static function apcu_cached_time($uniqueid) {
- $info = apcu_key_info($uniqueid);
- try{
- return $info['mtime']; //https://www.php.net/manual/en/function.apcu-key-info.php
- }
- catch(\Exception $ex){
- }
- return 0;
- }
- // apcu_clear_cache()
- // apcu_exists ($key)
- // apcu_delete ($key)
- /* apcu_cache_info()
- (
- [num_slots] => 4099
- [ttl] => 0
- [num_hits] => 3
- [num_misses] => 1
- [num_inserts] => 7
- [num_entries] => 7
- [expunges] => 16
- [start_time] => 1623695589
- [mem_size] => 20656376
- [memory_type] => mmap
- [cache_list] => array of members: https://www.php.net/manual/en/function.apcu-key-info.php
- [deleted_list] => []
- [slot_distribution] => [
- [176] => 1 [341] => 1 [940] => 1 ...
- ]
- )
- */
- ==============
- $timestamp = $this->apcu_cached_time ($uniqFileName);
- if (is_null($timestamp) || $timestamp + $expire_seconds<time() )
- {
- return $default;
- }
- $res = $this->apcu_get($uniqFileName);
- return ( !is_null($res) ? $res : $default );
Add Comment
Please, Sign In to add comment