Documentation

ResponseCacheItem
in package

Description of ResponseCacheItem

Tags
author

zozlak

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

NO_COMPRESSION

public mixed NO_COMPRESSION = 'image/*, audio/*, video/*, application/zip, application/gzip, application/x-bzip2, application/x-bzip, application/x-lzma'

Properties

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
self

getTtl()

public getTtl(int $resourceTtl, int $responseTtl) : int
Parameters
$resourceTtl : int
$responseTtl : int
Return values
int

send()

public send([bool|null $compress = null ]) : void
Parameters
$compress : bool|null = null

unify()

Testing helper

public unify(self $resp) : self
Parameters
$resp : self
Return values
self

withHit()

Helper for tests

public withHit(bool $hit) : self
Parameters
$hit : bool
Return values
self

withLastModified()

Helper for tests

public withLastModified(string $lastModified) : self
Parameters
$lastModified : string
Return values
self

getCompressFromContentTypeHeader()

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
bool

sendCompressed()

private sendCompressed(string $encoding) : void
Parameters
$encoding : string

        
On this page

Search results