class Cache (View source)

Constants

CACHED

FAILED

WRITING

DEFAULT_CHUNK_SIZE

Methods

__construct(string|null $method = null, string|null $target = null, string|null $query = null)

Define HTTP and request target. By default, the query string is not used; combine INPHINIT_PATH with $_SERVER[QUERY_STRING].

setLifetime($days, $hours, $minutes)

No description

setStorage(string $path)

Set storage location

int
start(int $chunkSize = null)

Starts recording the buffer to the cache, or serves it directly if a fresh copy exists.

stop()

Stops the cache and writes the content and headers obtained so far Note: Under normal circumstances, __destruct will execute this method automatically

__destruct()

No description

static string
createHash(string $path)

Create hash used by cache name and Etag header - This method can be overridden

static bool
match(string $etag, int $modified)

Check If-None-Match with ETag and If-Modified-Since with cache modified datetim

static bool
valid(int $status, string $method)

Checks if the HTTP status code and method are valid for caching – This method can be overridden.

Details

__construct(string|null $method = null, string|null $target = null, string|null $query = null)

Define HTTP and request target. By default, the query string is not used; combine INPHINIT_PATH with $_SERVER[QUERY_STRING].

Parameters

string|null $method

Optional. Default is $_SERVER[REQUEST_METHOD].

string|null $target

Optional. Default is INPHINIT_PATH.

string|null $query

Optional. Default is not to use a querystring.

setLifetime($days, $hours, $minutes)

No description

Parameters

$days
$hours
$minutes

setStorage(string $path)

Set storage location

Parameters

string $path

int start(int $chunkSize = null)

Starts recording the buffer to the cache, or serves it directly if a fresh copy exists.

  • Returns CACHED and serves the stored response if a fresh cache exists
  • Returns WRITING if recording of the current response just started
  • Returns FAILED if the method/cache is not writable, or the cache could not be created

Parameters

int $chunkSize

Return Value

int

Exceptions

ErrorException
Exception

stop()

Stops the cache and writes the content and headers obtained so far Note: Under normal circumstances, __destruct will execute this method automatically

__destruct()

No description

static protected string createHash(string $path)

Create hash used by cache name and Etag header - This method can be overridden

Parameters

string $path

Return Value

string

static protected bool match(string $etag, int $modified)

Check If-None-Match with ETag and If-Modified-Since with cache modified datetim

Parameters

string $etag
int $modified

Return Value

bool

static protected bool valid(int $status, string $method)

Checks if the HTTP status code and method are valid for caching – This method can be overridden.

Parameters

int $status
string $method

Return Value

bool