class WorkerCachedMaintenanceMode implements MaintenanceMode

Properties

static protected null|array{active: bool, data: array} $snapshot

The cached maintenance mode snapshot.

static protected float|null $refreshedAt

The time when the cached snapshot was last refreshed.

Methods

__construct(MaintenanceMode $driver, int $refreshInterval = 5)

Create a new worker-cached maintenance mode instance.

void
activate(array $payload)

Take the application down for maintenance.

void
deactivate()

Take the application out of maintenance.

bool
active()

Determine if the application is currently down for maintenance.

array
data()

Get the maintenance mode data payload.

static void
flushCache()

Flush the cached maintenance mode state.

array
loadSnapshot()

Load the maintenance mode snapshot from the underlying driver.

bool
shouldRefreshSnapshot()

Determine if the cached snapshot should be refreshed.

static float
now()

Get the current time as a Unix timestamp in seconds.

Details

at line 35
__construct(MaintenanceMode $driver, int $refreshInterval = 5)

Create a new worker-cached maintenance mode instance.

Parameters

MaintenanceMode $driver
int $refreshInterval

at line 44
void activate(array $payload)

Take the application down for maintenance.

Parameters

array $payload

Return Value

void

at line 54
void deactivate()

Take the application out of maintenance.

Return Value

void

at line 64
bool active()

Determine if the application is currently down for maintenance.

Return Value

bool

at line 72
array data()

Get the maintenance mode data payload.

Return Value

array

at line 80
static void flushCache()

Flush the cached maintenance mode state.

Return Value

void

at line 95
protected array loadSnapshot()

Load the maintenance mode snapshot from the underlying driver.

The active state and payload are read separately from the driver, then retained together so subsequent calls within the refresh interval use the same per-worker snapshot.

Return Value

array

at line 121
protected bool shouldRefreshSnapshot()

Determine if the cached snapshot should be refreshed.

Return Value

bool

at line 140
static protected float now()

Get the current time as a Unix timestamp in seconds.

This runs on every request through the global middleware stack, so the common path uses microtime() rather than Carbon interval arithmetic — building two Carbon instances and an interval to compare them costs microseconds where a float subtraction costs nanoseconds. Carbon is only consulted when a test now is set, so time travel still drives refreshes.

Return Value

float