All examples are based on the package's README and source at v1.8.1.4.
Select a storage driver
Pick a driver in config/pulse.php or the environment:
PULSE_STORAGE_DRIVER=database
Register a storage driver
A package or your app registers its own driver with extend. The callback gets the container and returns a Laravel\Pulse\Contracts\Storage:
use Laravel\Pulse\Contracts\Storage;use Laravel\Pulse\Fiber\Storage\StorageManager; public function boot(): void{ $this->app->make(StorageManager::class)->extend('clickhouse', function ($app): Storage { return new ClickHouseStorage($app['config']->get('pulse.storage.clickhouse')); });}
Then set PULSE_STORAGE_DRIVER=clickhouse. Implement every method on the Storage contract (store, trim, purge, values, graph, aggregate, aggregateTypes, aggregateTotal) and return the same shapes as DatabaseStorage; the cards depend on them.
Note: Avoid
staticclosures inextend, becauseManagerrebinds the callback to itself.
ClickHouseStorage is a placeholder for your own class.
Remember several queries concurrently
In a Livewire card, use RemembersConcurrently to run the cache misses of several queries at once:
use Laravel\Pulse\Facades\Pulse;use Laravel\Pulse\Fiber\Livewire\Concerns\RemembersConcurrently;use Laravel\Pulse\Livewire\Card; class MyCard extends Card{ use RemembersConcurrently; public function render() { $results = $this->rememberMany([ 'all' => fn ($interval) => Pulse::aggregate('cache_hit', ['count'], $interval), 'keys' => fn ($interval) => Pulse::aggregate('cache_hit', ['count'], $interval, limit: 25), ]); [$all, $allTime, $allRunAt] = $results['all']; // ... }}
Cache hits are returned as is; only the misses run, concurrently, through FiberDB::concurrent. On a shared PDO the storage lock serializes them, so this is safe but no faster than calling remember() in a row.
Reload the storage driver after a config change
On Octane and other long-lived workers, the driver instance is cached. After changing pulse.storage.* at runtime, drop the cached drivers:
use Laravel\Pulse\Fiber\Storage\StorageManager; app(StorageManager::class)->forgetDrivers();
Keep a child fiber from recording
The ignore() depth is per fiber and is not inherited by fibers started with Fledge\Async\async(). Wrap the child closure in ignore() as well if it must not record:
use Laravel\Pulse\Facades\Pulse; Pulse::ignore(function () { // Work in this fiber is not recorded.});