Repository navigation
CacheStore
Pair\Cache\CacheStore is the backend contract used by Cache and Idempotency. Implement it to provide an application-owned cache store without changing the facade.
| Method | Behavior |
|---|---|
get(string $key, mixed $default = null): mixed |
Returns a cached value or the fallback when missing or expired. |
set(string $key, mixed $value, ?int $ttlSeconds = null): bool |
Stores a serializable value; null means no expiration. |
has(string $key): bool |
Checks whether a live entry exists. |
delete(string $key): bool |
Deletes one entry. |
clear(): bool |
Clears entries owned by this store. |
Built-in implementations are FileCacheStore, ApcuCacheStore, and RedisCacheStore. See Cache for driver configuration and extension requirements.
use Pair\Cache\Cache;
use Pair\Cache\FileCacheStore;
Cache::setStore(new FileCacheStore(TEMP_PATH . 'application-cache'));Registering a store under AdapterKeys::CACHE only makes it available through the adapter registry; call Cache::setStore($store) to select it for the facade. Idempotency::setStore($store) configures idempotency separately; it does not automatically use the facade's selected store.
The interface has no atomic compare-and-set, increment, or sliding-window operations. Use RateLimiter for concurrent request throttling rather than combining get() and set() yourself.
See also: Cache, Idempotency, AdapterKeys, AdapterRegistry.
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4