Official Laravel source
AttributeIlluminate\Container\Attributes\Cache

#[Cache]

Attribute to cache the result of a parameter.

Available since

Laravel 13.0

Targets

parameter

Parameters

  • $storeUnitEnum|string|null

    Cache store to use.

Practical usage

use Illuminate\Container\Attributes\Cache;

class ReportsController {
    public function __invoke(#[Cache('redis')] mixed $data): array {
        return ['status' => 'ok'];
    }
}