CachingProxy
in package
Caching Proxy for Cover Images
Tags
Table of Contents
- $allowedHosts : array<string|int, mixed>
- Array of regular expressions for hosts to cache
- $cache : string
- Base directory for cache
- $client : Client
- HTTP client
- __construct() : mixed
- Constructor
- fetch() : Response
- Fetch an image from either a URL or the cache (as appropriate).
- fetchCache() : bool|Response
- Load a response from cache (or return false if cache is missing).
- getCacheFile() : string
- Get the cache filename corresponding with the provided URL.
- hasLegalHost() : bool
- Check if the URL is on the configured list for caching.
- setCache() : void
- Save a response to the cache.
Properties
$allowedHosts
Array of regular expressions for hosts to cache
protected
array<string|int, mixed>
$allowedHosts
$cache
Base directory for cache
protected
string
$cache
$client
HTTP client
protected
Client
$client
Methods
__construct()
Constructor
public
__construct(Client $client, string|null $cache[, array<string|int, mixed> $allowedHosts = [] ]) : mixed
Parameters
- $client : Client
-
HTTP client
- $cache : string|null
-
Base directory for cache (null to disable caching)
- $allowedHosts : array<string|int, mixed> = []
-
Array of regular expressions for hosts to cache
Return values
mixed —fetch()
Fetch an image from either a URL or the cache (as appropriate).
public
fetch(string $url) : Response
Parameters
- $url : string
-
URL to fetch
Return values
Response —fetchCache()
Load a response from cache (or return false if cache is missing).
protected
fetchCache(string $file) : bool|Response
Parameters
- $file : string
-
Cache file to load
Return values
bool|Response —getCacheFile()
Get the cache filename corresponding with the provided URL.
protected
getCacheFile(string $url) : string
Parameters
- $url : string
-
URL
Tags
Return values
string —hasLegalHost()
Check if the URL is on the configured list for caching.
protected
hasLegalHost(string $url) : bool
Parameters
- $url : string
-
URL to check
Return values
bool —setCache()
Save a response to the cache.
protected
setCache(string $file, Response $response) : void
Parameters
- $file : string
-
Filename to update
- $response : Response
-
Response to write