PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / htaccess-capability-tester / src / TestResultCache.php

TestResultCache.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/htaccess-capability-tester/src/TestResultCache.php

82 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HtaccessCapabilityTester;
4
5 use \HtaccessCapabilityTester\Testers\AbstractTester;
6
7 /**
8 * Class caching test results
9 *
10 * @package HtaccessCapabilityTester
11 * @author Bjørn Rosell <[email protected]>
12 * @since Class available since the beginning
13 */
14 class TestResultCache
15 {
16
17 /* @var array Array for caching */
18 protected static $cache;
19
20 /**
21 *
22 * @param array $cacheKeys Two keys for caching (usually: basedir and the getCacheKey() for the Tester)
23 * @param TestResult $testResult The test result to cache
24 *
25 * @return void
26 */
27 public static function cache($cacheKeys, $testResult)
28 {
29 if (!isset(self::$cache)) {
30 self::$cache = [];
31 }
32 list($key1, $key2) = $cacheKeys;
33 if (!isset(self::$cache[$key1])) {
34 self::$cache[$key1] = [];
35 }
36 self::$cache[$key1][$key2] = $testResult;
37 }
38
39 /**
40 * Check if in cache.
41 *
42 * @param array $cacheKeys Keys for caching (usually: basedir and the getCacheKey() for the Tester)
43 *
44 * @return bool
45 */
46 public static function isCached($cacheKeys)
47 {
48 if (!isset(self::$cache)) {
49 return false;
50 }
51 list($key1, $key2) = $cacheKeys;
52 if (!isset(self::$cache[$key1])) {
53 return false;
54 }
55 if (!isset(self::$cache[$key1][$key2])) {
56 return false;
57 }
58 return true;
59 }
60
61 /**
62 * Get from cache.
63 *
64 * @param array $cacheKeys Keys for caching (usually: basedir and the getCacheKey() for the Tester)
65 *
66 * @return TestResult The test result
67 */
68 public static function getCached($cacheKeys)
69 {
70 if (!self::isCached($cacheKeys)) {
71 throw new \Exception('Not in cache');
72 }
73 list($key1, $key2) = $cacheKeys;
74 return self::$cache[$key1][$key2];
75 }
76
77 public static function clear()
78 {
79 self::$cache = null;
80 }
81 }
82