diff --git a/src/cache/PhutilAPCKeyValueCache.php b/src/cache/PhutilAPCKeyValueCache.php index b103d20..bf7f7df 100644 --- a/src/cache/PhutilAPCKeyValueCache.php +++ b/src/cache/PhutilAPCKeyValueCache.php @@ -1,56 +1,97 @@ $value) { - apc_store($key, $value, $ttl); + if ($is_apcu) { + apcu_store($key, $value, $ttl); + } else { + apc_store($key, $value, $ttl); + } } return $this; } public function deleteKeys(array $keys) { + static $is_apcu; + if ($is_apcu === null) { + $is_apcu = self::isAPCu(); + } + foreach ($keys as $key) { - apc_delete($key); + if ($is_apcu) { + apcu_delete($key); + } else { + apc_delete($key); + } } return $this; } public function destroyCache() { - apc_clear_cache('user'); + static $is_apcu; + if ($is_apcu === null) { + $is_apcu = self::isAPCu(); + } + + if ($is_apcu) { + apcu_clear_cache(); + } else { + apc_clear_cache('user'); + } return $this; } + private static function isAPCU() { + return function_exists('apcu_fetch'); + } + }