Flare by Spatie
  • Features
  • Pricing
  • Docs
  • Blog
  • LOG IN
  • START TRACKING
  • Home
  • Features
  • Pricing
  • Docs
  • Blog
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript
  • General
  • Introduction
  • Installation
  • Censoring collected data
  • Ignoring collected data
  • Errors
  • Adding custom context
  • Customising error grouping
  • Handling errors
  • Linking to errors
  • Reporting errors
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and events
  • Data Collection
  • Application info
  • Application lifecycle
  • Cache events
  • Console commands
  • Customise error report
  • Database transactions
  • Dumps
  • Errors when tracing
  • Exception context
  • External http requests
  • Filesystem operations
  • Git information
  • Glows
  • Identifying users
  • Logs
  • Queries
  • Redis commands
  • Requests
  • Routing
  • Server info
  • Solutions
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Flare Client PHP V1

Cache events

An application can use a cache to store data that is expensive to compute. Flare can collect information about the cache events in your application.

Flare will collect the following information:

  • The cache key
  • The cache store
  • The cache operation (CacheOperation::Get, CacheOperation::Set, CacheOperation::Forget)
  • The cache result (CacheResult::Hit, CacheResult::Miss, CacheResult::Sucess, CacheResult::Failure)

It is possible to disable this behaviour by ignoring cache events in the Flare config:

$config->ignoreCacheEvents();

The amount of cache events tracked while collecting data in the case of an error can be configured as such:

$config->collectCacheEvents(maxItemsWithErrors: 50);

It is also possible to limit the types of cache operations that are collected:

$config->collectCacheEvents(
    operations: [
        CacheOperation::Get,
    ]
);

Collecting cache events

We cannot automatically collect cache events in the framework-agnostic version of the package. You can manually add cache events as such:

use Spatie\FlareClient\Enums\CacheOperation;
use Spatie\FlareClient\Enums\CacheResult;

$flare->cache()->record(
    key: 'my-key',
    store: 'redis',
    operation: CacheOperation::Get,
    result: CacheResult::Hit,
);

The following combinations of operations and results are possible:

Operation Result
CacheOperation::Get CacheResult::Hit
CacheOperation::Get CacheResult::Miss
CacheOperation::Set CacheResult::Success
CacheOperation::Set CacheResult::Failure
CacheOperation::Forget CacheResult::Success
CacheOperation::Forget CacheResult::Failure

It is possible to add extra attributes to a cache event as such:

$flare->cache()->record( 
    key: 'my-key',
    store: 'redis',
    operation: CacheOperation::Get,
    result: CacheResult::Hit,
    attributes: [
        'cache.value' => $value,
    ]
);
Application lifecycle Console commands
  • On this page
  • Collecting cache events

Monitor your web apps and sites from errors to slowdowns with Flare, the easiest application monitoring platform for Laravel, PHP & Javascript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Blog
  • Changelog
  • Documentation
  • Affiliate program
  • Service status
  • Terms of use
  • DPA
  • Privacy & Cookie Policy
Flare