Skip to content

WinCache Handler

Muhammet Şafak edited this page Jun 10, 2026 · 1 revision

WinCache Handler

⚠️ Deprecated. The WinCache extension is unmaintained and is not available for PHP 8. This handler is kept only for backward compatibility. On any modern stack use File, Redis or Memcache(d) instead.

InitPHP\Cache\Handler\Wincache stores items in the WinCache user cache (ext-wincache, Windows only).

Options

Option Type Default Description
prefix string cache_ Prepended to keys.
default_ttl int 0 Expiry used when set() is called without a TTL. 0 = no expiry.

Usage

use InitPHP\Cache\Cache;
use InitPHP\Cache\Handler\Wincache;

$cache = Cache::create(Wincache::class, [
    'default_ttl' => 300,
]);

$cache->set('key', 'value', 60);
$cache->get('key');

How it works

  • Values are stored with wincache_ucache_set(); TTLs are delegated to WinCache.
  • When set() is called without a TTL, the default_ttl option is applied (0 = no expiry).
  • has() uses wincache_ucache_exists().
  • clear() calls wincache_ucache_clear(), which clears the entire user cache — it is not limited by prefix.

Requirements

The handler is only supported when the extension is loaded and the user cache is enabled:

extension_loaded('wincache') && ini_get('wincache.ucenabled'); // must be true

Constructing the handler in an unsupported environment throws a CacheException — which, since the extension does not exist on PHP 8, is what you will get on any current runtime. Build a different handler instead.

Next steps

Clone this wiki locally