bedrockstreaming/stale-cache-bundle
CacheInterface, making it a seamless fit for applications already using Symfony’s caching ecosystem (e.g., CachePool, TagAwareCacheInterface). It avoids reinventing caching logic while adding stale-read functionality.Symfony\Contracts\Cache\CacheInterface, ensuring compatibility with modern Symfony versions while phasing out legacy AdapterInterface.@cache.app) can migrate incrementally.TagAwareCacheInterface, enabling stale behavior for tagged caches (e.g., cache:clear operations remain functional).max_stale) may mask backend failures, leading to silent data corruption. Requires clear documentation of acceptable stale windows per use case.UnavailableRegenerationException.AdapterInterface; applications using older Symfony cache APIs (pre-5.3) will need migration.max_stale) for each use case (e.g., 5s for dashboards, 60s for analytics)?cache:clear or require explicit stale-period expiration?CachePool or other cache abstractions that could conflict with this bundle?symfony/cache (e.g., API Platform, Symfony UX, or custom cache consumers).CacheInterface/TagAwareCacheInterface and legacy AdapterInterface.composer.json and enable in config/bundles.php.config/packages/bedrock_stale_cache.yaml:
bedrock_stale_cache:
decorated_cache_pools:
stale_api_cache:
cache_pool: cache.app
max_stale: 10 # 10 seconds
stale_analytics_cache:
cache_pool: cache.analytics
max_stale: 60
enable_debug_logs: true
cache.app injections with @stale_api_cache where stale reads are acceptable.Bedrock\StaleCacheBundle\Exception\UnavailableRegenerationException in cache consumers to implement fallback logic.try {
$data = $staleCache->get('key', fn() => fetchFreshData());
} catch (UnavailableRegenerationException $e) {
// Log and return cached stale data or throw for critical paths
}
Symfony\Component\Cache\Test\CacheTest).AdapterInterface must migrate to CacheInterface first.max_stale) may need tuning post-deployment based on real-world usage patterns.enable_debug_logs during troubleshooting to correlate stale-read events with regeneration failures.UnavailableRegenerationException.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cache backend unavailable | Stale reads return cached data; regeneration fails. | Monitor backend health; implement circuit breakers for regeneration calls. |
| Regeneration throws unexpected error | Stale item may not be returned if exception isn’t caught. | Wrap cache calls in try-catch; log unhandled exceptions. |
max_stale too long |
Data staleness masks backend issues, leading to undetected corruption. | Set conservative defaults; alert on high stale windows. |
| Tag invalidation race conditions | Stale items may persist after cache:clear if tags aren’t handled. |
Test tag invalidation paths; ensure stale periods align with TTLs. |
| Concurrent regeneration failures | Thundering herd during regeneration if many stale items fail. | Rate-limit regeneration calls; use exponential backoff. |
max_stale values and error handling.How can I help you explore Laravel packages today?