Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Illuminate Adapter Laravel Package

cache/illuminate-adapter

PSR-6 cache pool adapter for Laravel Illuminate cache stores. Wrap any Illuminate\Cache\Store (e.g., ArrayStore) to use via standard PSR-6 CacheItemPoolInterface. Part of the PHP-Cache organization with shared docs on tags and hierarchy.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • PSR-6 Standardization: Perfectly aligns with PSR-6 adoption goals, enabling cache abstraction across Laravel and non-Laravel services (e.g., Symfony, custom PHP). Eliminates vendor lock-in while preserving Laravel’s cache ecosystem.
  • Tagging Hierarchy: Leverages Laravel’s mature tagging system (Cache::tags()) for granular invalidation, critical for dynamic data (e.g., e-commerce, SaaS). PSR-6’s deleteByTag() integrates seamlessly.
  • Adapter Pattern: Minimal intrusion—wraps existing Illuminate\Cache\Store instances without modifying core logic. Ideal for incremental migration.
  • Modularity: Enables mixing cache backends (e.g., Redis for sessions, database for configs) under a unified PSR-6 interface.

Integration Feasibility

  • Zero-Breaking Changes: Replaces Cache::store() with PSR-6 calls (e.g., $pool->getItem('key')) without altering Laravel’s configuration.
  • Driver Agnosticism: Supports all Laravel cache drivers (RedisStore, DatabaseStore, etc.), including custom implementations.
  • Composer-Friendly: Single composer require with no transitive conflicts. MIT license allows internal modifications.
  • Testing: Validates PSR-6 compliance (e.g., getItem(), deleteMultiple()), but edge cases (e.g., getMultiple() with tags) may need manual testing.

Technical Risk

  • Stagnation Risk: Last release in 2022-01-17 with no recent activity. Risks:
    • PHP 8.2+/Laravel 10+: Untested compatibility (e.g., named arguments, attributes).
    • Deprecations: Laravel’s cache API may evolve (e.g., new store methods).
  • Undocumented Behavior: No visible test suite or CI/CD. Assumes reliability based on PHP-Cache org’s reputation.
  • Performance Overhead: Adapter layer may add <5% latency (benchmark required). Negligible for most use cases but critical for real-time systems.
  • Tagging Edge Cases: Potential race conditions in deleteByTag() if Laravel’s tagging system isn’t thread-safe.

Key Questions

  1. Laravel 10+ Support:
    • Does the adapter handle Laravel’s cache API changes (e.g., Cache::tags() method signatures)?
  2. PHP 8.2+ Compatibility:
    • Are there breaking changes with named arguments or attributes?
  3. Tagging Consistency:
    • How does deleteByTag() interact with Laravel’s tagging system under high concurrency?
  4. Driver-Specific Issues:
    • Are there known limitations with MemcachedStore or DatabaseStore (e.g., tagging performance)?
  5. Maintenance Plan:
    • Is the PHP-Cache org responsive to issues, or should we fork for critical projects?
  6. Benchmark Data:
    • What’s the real-world overhead vs. direct PSR-6 drivers (e.g., predis/predis)?
  7. Missing PSR-6 Features:
    • Does it support has() (PSR-6 1.1+) or other niche methods?

Integration Approach

Stack Fit

  • Ideal For:
    • Laravel Monoliths: Standardize caching for Doctrine, API Platform, or custom services.
    • Hybrid Architectures: Share cache pools between Laravel and Symfony/Lumen services.
    • Testing: Use ArrayStore for unit tests with PSR-6 interfaces.
    • Legacy Migration: Gradually introduce PSR-6 without rewriting cache logic.
  • Avoid If:
    • No PSR-6 Need: Already using Laravel’s cache directly without interoperability requirements.
    • High-Performance Caching: Direct PSR-6 drivers (e.g., predis/predis) may outperform the adapter.
    • Advanced Laravel Features: Relying on Cache::events() or other non-PSR-6 features.

Migration Path

  1. Assessment:
    • Audit cache usage: Identify PSR-6 consumers (e.g., Doctrine, Symfony) and non-PSR-6 calls (e.g., Cache::remember()).
    • Benchmark adapter vs. direct Laravel cache for critical paths (e.g., API rate limiting).
  2. Pilot:
    • Replace one PSR-6 consumer (e.g., a Symfony service) using ArrayStore for testing.
    • Validate tagging with deleteByTag() and getItem().
  3. Rollout:
    • Phase 1: Wrap the default cache store (e.g., Redis) in the adapter:
      $cache = new IlluminateCachePool(Cache::store('redis'));
      
    • Phase 2: Update PSR-6 consumers to use the new pool. Example:
      $item = $cache->getItem('user:123:profile');
      
    • Phase 3: Deprecate direct Laravel cache calls in favor of PSR-6 interfaces.
  4. Fallback:
    • Implement a feature flag to toggle between direct Laravel cache and the adapter during migration.

Compatibility

  • Laravel Cache Drivers:
    • Tested: ArrayStore, FileStore, RedisStore, DatabaseStore.
    • Untested: MemcachedStore, DynamoStore. Extend the adapter if needed.
  • PSR-6 Compliance:
    • Supports core methods (getItem(), save(), delete(), etc.) but lacks has() (PSR-6 1.1+). Polyfill if required.
    • Tagging: deleteByTag() works but may have edge cases under high concurrency.
  • PHP Versions:
    • Assumes PHP 7.4+. Test with PHP 8.1+ for JIT/attributes compatibility.
    • Workaround: Use a php-version constraint in composer.json if needed.

Sequencing

  1. Non-Critical Paths: Start with logging, analytics, or background jobs.
  2. Core Services: Migrate API rate limiting, session storage, or user sessions.
  3. Database Caching: Replace Cache::remember() in repositories with PSR-6 calls.
  4. Deprecation: Remove direct Laravel cache usage after validation.

Operational Impact

Maintenance

  • Pros:
    • Leverages Laravel Ecosystem: Use existing cache drivers (Redis, Memcached) with PSR-6.
    • Centralized Configuration: Manage stores via config/cache.php as usual.
  • Cons:
    • Dependency Risk: Stagnant package may require forking or patches.
    • Debugging Complexity: Errors may originate in Laravel’s cache or the adapter.
  • Mitigations:
    • Fork the package and maintain it internally if critical.
    • Add error handling to log adapter-specific failures:
      try {
          $item = $cache->getItem('key');
      } catch (Throwable $e) {
          Log::error("Cache adapter failed: " . $e->getMessage());
          // Fallback to direct Laravel cache
      }
      

Support

  • Documentation Gaps:
    • Missing: Driver-specific quirks, performance benchmarks, and tagging limitations.
    • Template:
      ## Troubleshooting
      ### Known Issues
      - `DatabaseStore` tagging may be slow under high load.
      - `FileStore` does not support distributed invalidation.
      ### Performance
      | Operation       | Overhead vs. Native | Notes                          |
      |-----------------|----------------------|--------------------------------|
      | `getItem()`     | <1%                  | Negligible                     |
      | `deleteByTag()` | 5–10%                | Test with Redis/Memcached      |
      
  • Community:
    • Limited activity (11 stars, no dependents). Engage the PHP-Cache Gitter for support.

Scaling

  • Horizontal Scaling:
    • Works with distributed backends (Redis, Memcached) but requires coordination for tag invalidation (e.g., Redis pub/sub).
  • Vertical Scaling:
    • Minimal overhead for simple operations. Complex operations (e.g., deleteMultiple()) may add latency.
    • Benchmark: Compare with predis/predis for Redis-specific workloads.
  • Resource Usage:
    • Memory: ~100–200KB per pool (negligible).
    • CPU: Minimal impact unless using slow drivers (e.g., DatabaseStore).

Failure Modes

Scenario Impact Mitigation
Adapter throws undocumented error PSR-6 consumer fails silently Implement retry logic or fallbacks
Laravel cache driver fails Cache pool becomes unusable Use circuit breakers (e.g., cache/adapter-common)
Tagging inconsistencies Stale data in consumers Validate with integration tests
PHP version incompatibility Runtime errors Pin to a compatible PHP
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle