PluginProbe
User Access Manager / trunk
User Access Manager vtrunk
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Cache/RedisCacheProvider.php +12 -10 2.3.14trunk View file →
@@ -6,22 +6,24 @@
6 6
7 7 use Exception;
8 8 use UserAccessManager\Config\Config;
9 9 use UserAccessManager\Config\ConfigFactory;
10 -use UserAccessManager\Config\ConfigParameterFactory;
10 +use UserAccessManager\Config\Parameter\ConfigParameterFactory;
11 +use UserAccessManager\Wrapper\Wordpress;
11 12
12 13 class RedisCacheProvider implements CacheProviderInterface
13 14 {
14 - const ID = 'RedisCacheProvider';
15 - const CONFIG_KEY = 'uam_redis_cache_provider';
16 - const CONFIG_PREFIX = 'redis_prefix';
17 - const CONFIG_TTL = 'redis_ttl';
18 - const DEFAULT_PREFIX = 'uam_cache';
19 - const DEFAULT_TTL = 0;
15 + public const ID = 'RedisCacheProvider';
16 + public const CONFIG_KEY = 'uam_redis_cache_provider';
17 + public const CONFIG_PREFIX = 'redis_prefix';
18 + public const CONFIG_TTL = 'redis_ttl';
19 + public const DEFAULT_PREFIX = 'uam_cache';
20 + public const DEFAULT_TTL = 0;
20 21
21 22 private ?Config $config = null;
22 23
23 24 public function __construct(
25 + private Wordpress $wordpress,
24 26 private ConfigFactory $configFactory,
25 27 private ConfigParameterFactory $configParameterFactory
26 28 ) {
27 29 }
@@ -77,14 +79,14 @@
77 79 }
78 80
79 81 public function add(string $key, mixed $value): void
80 82 {
81 - wp_cache_set($this->buildKey($key), $value, self::ID, $this->getTtl());
83 + $this->wordpress->wpCacheSet($this->buildKey($key), $value, self::ID, $this->getTtl());
82 84 }
83 85
84 86 public function get(string $key): mixed
85 87 {
86 - $value = wp_cache_get($this->buildKey($key), self::ID);
88 + $value = $this->wordpress->wpCacheGet($this->buildKey($key), self::ID);
87 89
88 90 // wp_cache_get returns false on a miss; normalize to null per interface contract.
89 91 return ($value === false) ? null : $value;
90 92 }
@@ -90,7 +92,7 @@
90 92 }
91 93
92 94 public function invalidate(string $key): void
93 95 {
94 - wp_cache_delete($this->buildKey($key), self::ID);
96 + $this->wordpress->wpCacheDelete($this->buildKey($key), self::ID);
95 97 }
96 98 }