cache/prefixed-cache
PSR-6 cache pool decorator that prefixes all cache item keys with a predefined string. Wrap any PSR-6 cache (e.g., Redis) to safely namespace entries per app, tenant, or module. Part of the PHP-Cache ecosystem.
tenant_1:user_123 vs. tenant_2:user_123), reducing risk of cross-tenant data leaks or cache pollution. Aligns with Laravel’s multi-tenant patterns (e.g., tenant() helper, HasTenants trait).feature_new_ui:, service_payment:). Reduces merge conflicts and simplifies cache invalidation during deployments.Redis::get() calls with Cache::remember() while isolating keys.php-cache/tagging-cache) if the team needs fine-grained cache invalidation or organization.redis driver with php-cache/redis-cache) or planning to migrate.spatie/laravel-cache-prefix (Laravel-specific) or cachetools/core (more actively maintained).Cache::prefix() or a custom wrapper instead.For Executives:
"This package lets us safely share a single caching layer (e.g., Redis) across multiple Laravel apps, tenants, or microservices without risking data leaks or cache pollution. For example, we could prefix tenant_1:api: and tenant_2:api: to isolate cache invalidations during rollouts—saving costs on dedicated cache instances while reducing operational complexity. It’s a $0, low-risk solution with no code changes required beyond wrapping our existing PSR-6 cache pools. The trade-off? Minimal maintenance effort, as the package is stable but no longer actively developed."
For Engineers:
*"The PrefixedCachePool wraps any PSR-6 cache (e.g., Redis, Memcached) and prepends a namespace to all keys. Use cases:
tenant_1:user_123).feature_new_ui:cache).How to use it in Laravel:
composer require cache/prefixed-cache php-cache/redis-cache
$redisPool = new RedisCachePool(new Redis());
$prefixedPool = new PrefixedCachePool($redisPool, 'tenant_1_');
Pros:
Cons:
spatie/laravel-cache-prefix).Recommendation: Start with a proof of concept for a non-critical cache store (e.g., sessions) and monitor performance. If maintenance becomes an issue, fork the package or switch to cachetools/core."*
How can I help you explore Laravel packages today?