| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* JCH Optimize - Performs several front-end optimizations for fast downloads |
| 5 |
* |
| 6 |
* @package jchoptimize/wordpress-platform |
| 7 |
* @author Samuel Marshall <samuel@jch-optimize.net> |
| 8 |
* @copyright Copyright (c) 2022 Samuel Marshall / JCH Optimize |
| 9 |
* @license GNU/GPLv3, or later. See LICENSE file |
| 10 |
* |
| 11 |
* If LICENSE file missing, see <http://www.gnu.org/licenses/>. |
| 12 |
*/ |
| 13 |
|
| 14 |
namespace JchOptimize\WordPress\Admin\Settings; |
| 15 |
|
| 16 |
use function class_exists; |
| 17 |
use function extension_loaded; |
| 18 |
use function function_exists; |
| 19 |
use function ini_get; |
| 20 |
use function strcmp; |
| 21 |
|
| 22 |
abstract class CacheStorageSupport |
| 23 |
{ |
| 24 |
/** |
| 25 |
* Test to see if the APCU storage handler is available. |
| 26 |
* |
| 27 |
* @return bool |
| 28 |
*/ |
| 29 |
public static function isApcuSupported(): bool |
| 30 |
{ |
| 31 |
$supported = extension_loaded('apcu') && ini_get('apc.enabled'); |
| 32 |
|
| 33 |
// If on the CLI interface, the `apc.enable_cli` option must also be enabled |
| 34 |
if ($supported && PHP_SAPI === 'cli') { |
| 35 |
$supported = ini_get('apc.enable_cli'); |
| 36 |
} |
| 37 |
|
| 38 |
return (bool)$supported; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Test to see if the Memcached storage handler is available. |
| 43 |
* |
| 44 |
* @return bool |
| 45 |
*/ |
| 46 |
public static function isMemcachedSupported(): bool |
| 47 |
{ |
| 48 |
/* |
| 49 |
* GAE and HHVM have both had instances where Memcached the class was defined but no extension was loaded. |
| 50 |
* If the class is there, we can assume support. |
| 51 |
*/ |
| 52 |
return class_exists('Memcached'); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Test to see if the Redis storage handler is available. |
| 57 |
* |
| 58 |
* @return bool |
| 59 |
*/ |
| 60 |
public static function isRedisSupported(): bool |
| 61 |
{ |
| 62 |
return class_exists('\\Redis'); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Test to see if the Wincache storage handler is available. |
| 67 |
* |
| 68 |
* @return bool |
| 69 |
*/ |
| 70 |
public static function isWincacheSupported(): bool |
| 71 |
{ |
| 72 |
return extension_loaded('wincache') && function_exists('wincache_ucache_get') && !strcmp( |
| 73 |
ini_get('wincache.ucenabled'), |
| 74 |
'1' |
| 75 |
); |
| 76 |
} |
| 77 |
} |
| 78 |
|