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

In Memory Cache Laravel Package

beste/in-memory-cache

PSR-6 compliant in-memory cache for PHP—ideal as a lightweight default cache and for fast, predictable tests. Supports standard CacheItemPoolInterface behavior and optional PSR-20 clocks (e.g., frozen clocks) for time-based expiry testing.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: Excellent for Laravel's PSR-6 compliant cache system. Laravel natively supports PSR-6 interfaces, enabling seamless integration as a custom driver without adapter layers. The package's simplicity aligns with Laravel's modular cache architecture where drivers can be swapped via configuration.

Integration feasibility: High. Requires minimal effort to create a Laravel cache driver that wraps InMemoryCache. Composer dependency management handles all required PSR packages, and no additional configuration beyond driver registration is needed.

Technical risk: Low for intended use cases (tests/fallback), but critical if misapplied to production environments. Key risks include accidental production deployment due to misconfiguration, lack of persistence, and no cross-process sharing.

Key questions:

  • How will we prevent accidental production use (e.g., environment checks in driver configuration)?
  • What's the strategy for migrating from in-memory to production cache without code changes?
  • How to handle memory management in long-running CLI tests?

Integration Approach

Stack fit: Fits perfectly within Laravel's cache driver architecture. Can be implemented as a custom driver (e.g., 'in_memory') using PSR-6 compliance, requiring no additional dependencies beyond the package itself.

Migration path:

  1. Install package via Composer (composer require beste/in-memory-cache).
  2. Create a Laravel cache driver class that implements Illuminate\Contracts\Cache\Repository by delegating to InMemoryCache.
  3. Register the driver in config/cache.php under 'stores'.
  4. Switch to 'in_memory' in .env for local/testing environments. No application logic changes needed.

Compatibility: Fully compatible with Laravel's cache system due to PSR-6 adherence. Works with all Laravel versions supporting PSR-6 (Laravel 5.7+). No conflicts with existing cache drivers.

Sequencing:

  • Phase 1: Use in local development and CI tests to replace external cache dependencies.
  • Phase 2: After feature development, switch to production cache (e.g., Redis) in staging/prod environments.
  • Phase 3: Monitor for issues during transition, ensuring all cache interactions are abstracted via Laravel's cache facade.

Operational Impact

Maintenance: Minimal overhead. The package is stable with clear versioning and no active dependency management issues. Maintenance mainly involves monitoring for Laravel updates that might affect cache drivers, but since it's a simple wrapper, this is rare.

Support: Limited community support due to low dependents (0), but the package is small and well-documented. Internal engineering team can handle troubleshooting. Critical to document usage guidelines to prevent misconfiguration.

Scaling: Not applicable for production scaling. In test environments, memory usage scales linearly with cache items. For large test suites, recommend periodic cache clearing or clear() in test teardown to prevent memory bloat.

Failure modes:

  • Data loss on process termination (expected for in-memory cache).
  • Accidental production deployment leading to cache misses and data inconsistency.
  • No recovery mechanism for cache corruption (though unlikely as it's simple array storage).

Ramp-up: Very low. Engineers can start using it immediately after installation. Documentation is clear with usage examples. Training required only to emphasize "do not use in production" and proper test isolation practices.

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4