tedivm/stash-bundle
Symfony bundle integrating the Stash caching library. Provides cache pool services, Web Profiler toolbar info, and Doctrine Common Cache integration. Supports multiple cache backends with simple YAML configuration and easy access to default or custom pools.
TedivmStashBundle is a Symfony-specific wrapper for the Stash caching library, making it a natural fit for Symfony-based applications (v3.4+ and Symfony 5+).Apc + FileSystem fallback), enabling high availability and performance optimization by leveraging multiple backends (e.g., Redis, Memcached, APC, SQLite, or filesystem).drivers: [Apc, FileSystem]), with sensible defaults.first, second), preventing key conflicts in shared environments.| Risk Area | Assessment | Mitigation |
|---|---|---|
| Driver Dependency | Relies on external drivers (e.g., Apc, Redis). Missing drivers break functionality. |
Use fallback chains (e.g., Apc → FileSystem) and validate driver availability at runtime. |
| Symfony Version Lock | Last release (2023-05-24) may lag behind Symfony 6/7 features. | Monitor upstream Stash updates; test against Symfony 6+ if critical. |
| Memory Leaks | In-memory caching (default) may cause leaks in long-running CLI processes. | Disable inMemory: false for CLI scripts or use dedicated drivers (e.g., Redis). |
| Key Management | No built-in key TTL validation or eviction policies. | Implement cache key namespacing and explicit TTLs in application logic. |
| Debugging Complexity | Composite drivers obscure cache misses/hits. | Enable tracking: true in dev env and use Web Profiler integration. |
Performance Requirements:
Redis → FileSystem) be needed for high availability?Operational Constraints:
FileSystem or Memcached may be mandatory.Compatibility:
DoctrineAdapter simplifies cache configuration.registerDoctrineAdapter) may need manual setup.Maintenance:
tracking) and adjust TTLs/drivers?Alternatives:
symfony/cache) or Doctrine Cache?
| Component | Fit Level | Notes |
|---|---|---|
| Symfony 5/6 | ✅ Native | Designed for Symfony; uses AppKernel registration and YAML config. |
| Laravel | ⚠️ Partial | Not Laravel-native, but could be adapted via Laravel’s Symfony Bridge or custom service provider. |
| PHP 8.0+ | ✅ Supported | Explicit PHP 8.0+ compatibility (e.g., fix php8 compatibility in v0.7.1). |
| Doctrine ORM | ✅ Native | DoctrineAdapter integrates seamlessly with metadata_cache, query_cache, etc. |
| Redis/Memcached | ✅ First-Class | Native driver support with configurable options (e.g., servers, weight). |
| CLI Applications | ⚠️ Manual | In-memory caching may cause leaks; disable with inMemory: false. |
Assessment Phase:
Symfony Cache, Doctrine Cache, or custom solutions).Pilot Integration:
FileSystem) for validation.config.yml:
stash:
drivers: [FileSystem]
FileSystem:
path: "%kernel.cache_dir%/stash"
Gradual Rollout:
Redis → FileSystem) for high availability.stash:
drivers: [Redis]
registerDoctrineAdapter: true
Redis:
servers:
- { server: "redis://localhost", port: 6379 }
doctrine:
orm:
metadata_cache_driver: stash.adapter.doctrine.default_cache
ApcUserCache) with Stash equivalents.Optimization:
stash.tracking: true) to analyze hit/miss ratios.| Feature | Compatibility |
|---|---|
| Symfony 6 Flex | ❌ No native support; manual AppKernel registration required. |
| Laravel Adaptation | ✅ Possible via custom service provider or Laravel’s Symfony components. |
| PHP 7.4–8.2 | ✅ Tested; no breaking changes in recent releases. |
| Doctrine 2.7+ | ✅ Full support via DoctrineAdapter. |
| Legacy Symfony 3.4 | ✅ Supported, but some features (e.g., registerSessionHandler) may need tweaks. |
Phase 1: Basic Caching
file_get_contents + manual serialization) with Stash.$pool = $this->get('stash');
$item = $pool->getItem('user_123_data');
if (!$item->isHit()) {
$item->set($this->loadUserData(123), 3600); // 1-hour TTL
}
Phase 2: Doctrine Integration
metadata_cache, query_cache, and result_cache to Stash.doctrine:
orm:
query_cache_driver: stash.adapter.doctrine.default_cache
Phase 3: Advanced Drivers
Redis → FileSystem).Phase 4: Monitoring & Tuning
stash.tracking: true in dev env.| Aspect | Effort | Notes |
|---|---|---|
| Configuration | Low | YAML-based; minimal boilerplate. |
| Driver Updates | Medium | External drivers (e.g., Redis) may require updates independently. |
| Key Management | Medium | Namespacing required for multi |
How can I help you explore Laravel packages today?