Cache
The app wires the framework cache manager through App\Providers\CacheServiceProvider and config/cache.php.
Use cache for short-lived computed values, lookup results, or other data that can be safely rebuilt.
Configuration
Cache config lives in:
config/cache.php
The default cache store is selected by:
CACHE_STORE=local
Redis cache settings:
CACHE_REDIS_CONNECTION=default
CACHE_REDIS_PREFIX=cache:
Stores
The app ships with:
local: file cache understorage/cacheredis: Redis-backed cache using the configured Redis connection
Recommended usage:
- use
localfor development and small single-node apps - use
rediswhen multiple app nodes need to share cached values
Basic Usage
Using the facade:
use Myxa\Support\Facades\Cache;
Cache::put('users.count', 15);
$count = Cache::get('users.count');
Cache::remember('dashboard.stats', fn () => ['ready' => true], 300);
Cache::forget('users.count');
TTL values are in seconds.
Use a named store when needed:
Cache::put('reports.ready', true, ttl: 300, store: 'redis');
Commands
Clear the configured store:
./myxa cache:clear
Clear a named store:
./myxa cache:clear --store=local
Forget one key:
./myxa cache:forget users:123
./myxa cache:forget dashboard:stats --store=local
Use cache:forget for targeted invalidation. Use cache:clear for a full store flush.
Route Cache
Route caching is separate from application cache values.
Build the route cache:
./myxa route:cache
Clear it:
./myxa route:clear
Routes are not cached until you run route:cache.
Notes
- Cache values should be safe to lose and rebuild.
- Prefer explicit TTLs for data that can become stale.
- Use Redis for shared cache state across multiple app nodes.
- Route cache and application cache are separate systems.
Related Guides
- Configuration
- HTTP Routing
- Rate Limiting and Throttling
vendor/200mph/myxa-framework/src/Cache/README.md