ResponseCacheItem
in package
Description of ResponseCacheItem
Tags
Table of Contents
Constants
- ETAG_HASH = 'xxh128'
- NO_COMPRESSION = 'image/*, audio/*, video/*, application/zip, application/gzip, application/x-bzip2, application/x-bzip, application/x-lzma'
- OUTPUT_CHUNK = 1048576
Properties
- $body : string
- $etag : string
- $file : bool
- $headers : array<string|int, mixed>
- $hit : bool
- $lastModified : string
- $resourceTimestamp : int
- $responseCode : int
- $responseTimestamp : int
Methods
- __construct() : mixed
- deserialize() : self
- getTtl() : int
- send() : void
- serialize() : string
- unify() : self
- Testing helper
- withHit() : self
- Helper for tests
- withLastModified() : self
- Helper for tests
- getCompressFromContentTypeHeader() : bool
- Automatically detects if it makes sense to compress the output based on the response format provided in the conte-type response header.
- getFileHash() : string
- sendCompressed() : void
Constants
ETAG_HASH
public
mixed
ETAG_HASH
= 'xxh128'
NO_COMPRESSION
public
mixed
NO_COMPRESSION
= 'image/*, audio/*, video/*, application/zip, application/gzip, application/x-bzip2, application/x-bzip, application/x-lzma'
OUTPUT_CHUNK
public
mixed
OUTPUT_CHUNK
= 1048576
Properties
$body read-only
public
string
$body
= ''
$etag read-only
public
string
$etag
$file read-only
public
bool
$file
= false
$headers
public
array<string|int, mixed>
$headers
= []
$hit read-only
public
bool
$hit
= false
$lastModified read-only
public
string
$lastModified
$resourceTimestamp read-only
public
int
$resourceTimestamp
$responseCode read-only
public
int
$responseCode
= 0
$responseTimestamp read-only
public
int
$responseTimestamp
Methods
__construct()
public
__construct([string $body = '' ][, int $responseCode = 0 ][, array<string, string|array<string|int, string>> $headers = [] ][, bool $hit = false ][, bool $file = false ][, string $etag = '' ][, string $lastModified = '' ][, int|null $responseTimestamp = null ][, int|null $resourceTimestamp = null ]) : mixed
Parameters
- $body : string = ''
- $responseCode : int = 0
- $headers : array<string, string|array<string|int, string>> = []
- $hit : bool = false
- $file : bool = false
- $etag : string = ''
- $lastModified : string = ''
- $responseTimestamp : int|null = null
- $resourceTimestamp : int|null = null
deserialize()
public
static deserialize(string $data, string $createdDate, int $resourceTimestamp) : self
Parameters
- $data : string
- $createdDate : string
- $resourceTimestamp : int
Return values
selfgetTtl()
public
getTtl(int $resourceTtl, int $responseTtl) : int
Parameters
- $resourceTtl : int
- $responseTtl : int
Return values
intsend()
public
send([bool|null $compress = null ]) : void
Parameters
- $compress : bool|null = null
serialize()
public
serialize() : string
Return values
stringunify()
Testing helper
public
unify(self $resp) : self
Parameters
- $resp : self
Return values
selfwithHit()
Helper for tests
public
withHit(bool $hit) : self
Parameters
- $hit : bool
Return values
selfwithLastModified()
Helper for tests
public
withLastModified(string $lastModified) : self
Parameters
- $lastModified : string
Return values
selfgetCompressFromContentTypeHeader()
Automatically detects if it makes sense to compress the output based on the response format provided in the conte-type response header.
private
getCompressFromContentTypeHeader() : bool
Return values
boolgetFileHash()
private
getFileHash() : string
Return values
stringsendCompressed()
private
sendCompressed(string $encoding) : void
Parameters
- $encoding : string