config === null) { $this->config = $this->configFactory->createConfig(self::CONFIG_KEY); $configParameters = [ self::CONFIG_PREFIX => $this->configParameterFactory->createStringConfigParameter( self::CONFIG_PREFIX, self::DEFAULT_PREFIX ), self::CONFIG_TTL => $this->configParameterFactory->createStringConfigParameter( self::CONFIG_TTL, (string) self::DEFAULT_TTL ), ]; $this->config->setDefaultConfigParameters($configParameters); } return $this->config; } private function getPrefix(): string { return (string) ($this->config?->getParameterValue(self::CONFIG_PREFIX) ?? self::DEFAULT_PREFIX); } private function getTtl(): int { return (int) ($this->config?->getParameterValue(self::CONFIG_TTL) ?? self::DEFAULT_TTL); } private function buildKey(string $key): string { return $this->getPrefix() . '|' . $key; } public function add(string $key, mixed $value): void { $this->wordpress->wpCacheSet($this->buildKey($key), $value, self::ID, $this->getTtl()); } public function get(string $key): mixed { $value = $this->wordpress->wpCacheGet($this->buildKey($key), self::ID); // wp_cache_get returns false on a miss; normalize to null per interface contract. return ($value === false) ? null : $value; } public function invalidate(string $key): void { $this->wordpress->wpCacheDelete($this->buildKey($key), self::ID); } }