class ModelCacheCoordinator

Coordinate shared model cache fills and exact invalidations.

Constants

private FILL_LOCK_SECONDS

The duration of a model cache fill lock.

private INVALIDATION_WAIT_SECONDS

The maximum time an invalidation waits for a fill lock.

private INVALIDATION_RETRY_MILLISECONDS

The delay between invalidation lock acquisition attempts.

private MUTATION_BATCH_SIZE

The maximum number of models written and invalidated per batch.

private ENVELOPE_MARKER_KEY

The envelope marker key.

private ENVELOPE_MARKER_VALUE

The envelope marker value.

private ENVELOPE_VALUE_KEY

The envelope value key.

Methods

__construct(Container $container)

Create a model cache coordinator.

bool
hasApplicableTransaction(Closure $source)

Determine whether the source has a transaction that prevents shared caching.

mixed
fill(Repository $cache, Closure $source, string $key, int $ttl, Closure $read, bool $cacheNull = true, Closure|null $writeCache = null)

Retrieve or fill a shared model cache entry.

int
mutate(Builder $query, Closure $write, Closure $invalidate)

Mutate selected models atomically and invalidate each written batch.

bool
invalidate(Repository $cache, string $key)

Invalidate an exact shared model cache entry.

Details

at line 63
__construct(Container $container)

Create a model cache coordinator.

Parameters

Container $container

at line 72
bool hasApplicableTransaction(Closure $source)

Determine whether the source has a transaction that prevents shared caching.

Parameters

Closure $source

Return Value

bool

at line 88
mixed fill(Repository $cache, Closure $source, string $key, int $ttl, Closure $read, bool $cacheNull = true, Closure|null $writeCache = null)

Retrieve or fill a shared model cache entry.

Parameters

Repository $cache
Closure $source
string $key
int $ttl
Closure $read
bool $cacheNull
Closure|null $writeCache

Return Value

mixed

at line 160
int mutate(Builder $query, Closure $write, Closure $invalidate)

Mutate selected models atomically and invalidate each written batch.

Parameters

Builder $query
Closure $write
Closure $invalidate

Return Value

int

at line 205
bool invalidate(Repository $cache, string $key)

Invalidate an exact shared model cache entry.

Parameters

Repository $cache
string $key

Return Value

bool