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

FAQ

Which handler should I use?

  • Local development / small sites: File — zero setup.
  • You already run a database, no extra service wanted: PDO.
  • Hot, shared cache across servers: Redis or Memcache(d).
  • WinCache: don't — it's deprecated and unavailable on PHP 8.

See the comparison table on the Home page.

Is this a PSR-16 cache?

Yes. Every handler implements Psr\SimpleCache\CacheInterface (via CacheInterface), so you can use it anywhere a PSR-16 cache is expected, and the package provides psr/simple-cache-implementation.

Can I store null / false?

Yes — any serialisable value round-trips exactly. Because get() also returns its default on a miss, use has() to tell a stored null from a miss. See Keys, TTL & Values.

Why did my key throw an InvalidArgumentException?

The key was empty or contained a PSR-16 reserved character ({}()/\@:). Common culprits are : (e.g. user:42) and /. Use . or _ instead, or hash untrusted input. See Keys, TTL & Values.

What does a TTL of 0 do?

It deletes the item (it's already expired), and set() returns true. Use null for "no expiry". See TTL.

Does clear() only remove my keys?

It depends on the backend:

  • File and PDO clear only items with the handler's prefix.
  • Redis runs FLUSHDB (the whole selected database) and Memcache(d)/WinCache flush the whole store.

For Redis, isolate with a dedicated database; for Memcached, a dedicated instance.

Are increment() / decrement() atomic?

No. They are uniform across handlers but implemented as read-modify-write, so they can race under concurrency. For strict atomic counters, use the backend's native command in its own keyspace. See Counters.

Does increment keep the item's TTL?

No — increment()/decrement() store the new value without an expiry. If you need a windowed counter, manage the TTL with set(). See the soft rate limiter.

Can I change options after creating the handler?

Yes: setOptions(['key' => 'value']) merges (case-insensitively) and returns the handler. Read one back with getOption('key', $default). See The Cache Factory.

The PDO handler — does it create the table?

No. Create the table yourself with the schema for your database; the PDO Handler page has ready-made CREATE TABLE statements for MySQL, SQLite and PostgreSQL.

Does it work without Redis/Memcached extensions?

The File handler needs nothing beyond PHP core, and PDO needs only ext-pdo. The Redis and Memcache handlers need their respective C extensions. Pre-check with isSupported() and fall back. See Installation.

How do I cache in tests without a server?

Use a small in-memory handler (or the File handler with a temp dir). See Testing.

Can I add my own backend?

Yes — extend BaseHandler and implement six methods. See Custom Handlers.

Still stuck?

Clone this wiki locally