Skip to content

Conversation

@jessarcher
Copy link
Member

When using the failover cache, currently the cache events have a null storeName:

Event::listen([
    CacheHit::class,
    CacheMissed::class,
], dump(...));

Cache::store('failover')->remember('time', 10, fn () => now()->toDateTimeString());


Illuminate\Cache\Events\CacheHit {
  +storeName: null
  +key: "time"
  +tags: []
  +value: "2025-10-23 06:11:09"
}

This is because the failover config is not currently passed to the Illuminate\Cache\Respository instance.

However, if we were to just pass the config, then the events would have the name failover, which I don't think is ideal:

Illuminate\Cache\Events\CacheHit {
  +storeName: "failover"
  +key: "time"
  +tags: []
  +value: "2025-10-23 06:14:18"
}

Instead, this PR disables events for the repository that wraps the FailoverStore store, and modifies it to call the underlying repositories, instead of the underlying stores, so that cache events are emitted with the underlying store name:

Illuminate\Cache\Events\CacheHit {
  +storeName: "database"
  +key: "time"
  +tags: []
  +value: "2025-10-23 06:16:30"
}

This is similar to the MemoizedStore which also disables events for itself, and calls the underlying repository, rather than the underlying store.

@taylorotwell taylorotwell merged commit 6d97175 into 12.x Oct 23, 2025
69 checks passed
@taylorotwell taylorotwell deleted the cache-event-store-name-on-failover branch October 23, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants