beste/in-memory-cache
Lightweight PSR-6 in-memory cache for PHP. Ideal as a default cache implementation and for fast, dependency-free tests. Supports expirations and can use a PSR-20 clock (e.g. frozen clock) for deterministic time-based behavior.
array()-based caches) with a PSR-6-compliant, actively maintained solution. Saves ~2–4 hours of dev time per project.config/cache.php.CACHE_DRIVER=in_memory in .env.testing).array() or Symfony\Component\Cache\Simple\ArrayCache) to a standardized PSR-6 solution.*"This package lets us eliminate unreliable external dependencies in our caching layer, reducing test flakiness and deployment risks. By adopting it:
*"The beste/in-memory-cache package gives us:
*"This package is your new best friend for caching in Laravel. Here’s why:
composer require beste/in-memory-cache and you’re done.Cache::shouldReceive() with real in-memory assertions. No more mocking PSR-6 interfaces.CACHE_DRIVER=in_memory in .env and never touch Redis again for non-critical stuff.// In tests:
$cache = new Beste\Cache\InMemoryCache();
$cache->save($cache->getItem('key')->set('value'));
$this->assertTrue($cache->getItem('key')->isHit());
// In Laravel config/cache.php:
'in_memory' => [
'driver' => 'cache',
'store' => Beste\Cache\InMemoryCache::class,
],
Pro Tip: Pair it with beste/clock for frozen-time testing in TTL scenarios."*
*"This package fixes our biggest test pain point: unreliable cache dependencies. Here’s how:
Cache::clear() on demand (e.g., in health checks).
Recommendation: Use it for all test environments and as a secondary cache driver in staging/prod with strict TTLs."**"This is a low-risk, high-reward investment for our tech stack:
How can I help you explore Laravel packages today?