Begin by installing via Composer: composer require illuminate/cache. Then configure the cache store using Laravel's config/cache.php (if using full Laravel) or manually instantiate the CacheManager and provide a Repository with a configured store (e.g., ArrayStore, FileStore, RedisStore). For initial exploration, use the ArrayStore in memory—it’s zero-configuration and ideal for testing. First use case: caching the result of an expensive function with Cache::remember('key', $ttl, fn() => expensiveOperation()).
Cache::tags(['users', 'posts'])->remember('users:1', $ttl, ...), though note tag support is limited to TaggedCache implementations (e.g., Redis, Memcached).Cache::lock('name', $timeout) for distributed locking, and combine with Cache::pull('token') for one-time consumption (e.g., OAuth callbacks).Illuminate\Contracts\Cache\Store for niche persistence layers (e.g., DynamoDB, custom DB table).Cache::() calls in a service class to enable mocking in tests and consistent TTL/key naming (e.g., App\Services\ArticleCache::getLatest()).null vs false distinction matters—Cache::put('key', false) stores false, but Cache::remember('key', $ttl, fn() => null) stores null; ensure your retrieval logic doesn’t conflate missing keys with falsy values.ArrayStore resets on each request—never use it in production. Default file store serializes entries but doesn’t auto-detect Laravel’s CACHE_DRIVER unless using the CacheManager.FileStore with tags() silently ignores tags or throws if the underlying TaggedCache isn’t properly constructed.0 or null TTL means “forever” in most stores, but ArrayStore ignores TTL entirely. Use Carbon::now()->addMinutes(5) instead of raw seconds to avoid confusion.Cache::listen(fn($event) => logger($event))) to trace misses, hits, and key collisions. Check storage/logs/cache.log for failed writes (e.g., permission issues on storage/framework/cache).How can I help you explore Laravel packages today?