Cache implements CacheInterface
Cache class. Provides methods to manage cache files for assets, pages, and other data.
Table of Contents
Interfaces
- CacheInterface
Properties
Methods
- __construct() : mixed
- clear() : bool
- {@inheritdoc}
- clearByPattern() : int
- Clear cache by pattern.
- createKey() : string
- Creates key from a name and a hash: "$name__HASH__VERSION".
- createKeyFromAsset() : string
- Creates key from an Asset: "$path_$ext_$tags__HASH__VERSION".
- createKeyFromFile() : string
- Creates key from a file: "RelativePathname__MD5".
- createKeyFromValue() : string
- Creates key from a string: "$name__HASH__VERSION".
- delete() : bool
- {@inheritdoc}
- deleteMultiple() : bool
- {@inheritdoc}
- get() : mixed
- {@inheritdoc}
- getContentFilePathname() : string
- Returns cache content file pathname from path.
- getMultiple() : iterable<string|int, mixed>
- {@inheritdoc}
- has() : bool
- {@inheritdoc}
- sanitizeKey() : string
- Prepares and validate $key.
- set() : bool
- {@inheritdoc}
- setMultiple() : bool
- {@inheritdoc}
- deleteContentFile() : bool
- Removes the cache content file.
- duration() : int
- Convert the various expressions of a TTL value into duration in seconds.
- getFilePathname() : string
- Returns cache file pathname from key.
- prune() : bool
- Removes previous cache files.
Properties
$builder
protected
Builder
$builder
$cacheDir
protected
string
$cacheDir
Methods
__construct()
public
__construct(Builder $builder[, string $pool = '' ]) : mixed
Parameters
- $builder : Builder
- $pool : string = ''
clear()
{@inheritdoc}
public
clear() : bool
Return values
boolclearByPattern()
Clear cache by pattern.
public
clearByPattern(string $pattern) : int
Parameters
- $pattern : string
Return values
intcreateKey()
Creates key from a name and a hash: "$name__HASH__VERSION".
public
createKey(string $name, string $hash) : string
Parameters
- $name : string
- $hash : string
Return values
stringcreateKeyFromAsset()
Creates key from an Asset: "$path_$ext_$tags__HASH__VERSION".
public
createKeyFromAsset(Asset $asset[, array<string|int, mixed>|null $tags = null ]) : string
Parameters
- $asset : Asset
- $tags : array<string|int, mixed>|null = null
Return values
stringcreateKeyFromFile()
Creates key from a file: "RelativePathname__MD5".
public
createKeyFromFile(SplFileInfo $file) : string
Parameters
- $file : SplFileInfo
Tags
Return values
stringcreateKeyFromValue()
Creates key from a string: "$name__HASH__VERSION".
public
createKeyFromValue(string|null $name, string $value) : string
$name is optional to add a human readable name to the key.
Parameters
- $name : string|null
- $value : string
Return values
stringdelete()
{@inheritdoc}
public
delete(mixed $key) : bool
Parameters
- $key : mixed
Return values
booldeleteMultiple()
{@inheritdoc}
public
deleteMultiple(mixed $keys) : bool
Parameters
- $keys : mixed
Return values
boolget()
{@inheritdoc}
public
get(mixed $key[, mixed $default = null ]) : mixed
Parameters
- $key : mixed
- $default : mixed = null
getContentFilePathname()
Returns cache content file pathname from path.
public
getContentFilePathname(string $path) : string
Parameters
- $path : string
Return values
stringgetMultiple()
{@inheritdoc}
public
getMultiple(mixed $keys[, mixed $default = null ]) : iterable<string|int, mixed>
Parameters
- $keys : mixed
- $default : mixed = null
Return values
iterable<string|int, mixed>has()
{@inheritdoc}
public
has(mixed $key) : bool
Parameters
- $key : mixed
Return values
boolsanitizeKey()
Prepares and validate $key.
public
static sanitizeKey(string $key) : string
Parameters
- $key : string
Return values
stringset()
{@inheritdoc}
public
set(mixed $key, mixed $value[, mixed $ttl = null ]) : bool
Parameters
- $key : mixed
- $value : mixed
- $ttl : mixed = null
Return values
boolsetMultiple()
{@inheritdoc}
public
setMultiple(mixed $values[, mixed $ttl = null ]) : bool
Parameters
- $values : mixed
- $ttl : mixed = null
Return values
booldeleteContentFile()
Removes the cache content file.
protected
deleteContentFile(string $path) : bool
Parameters
- $path : string
Return values
boolduration()
Convert the various expressions of a TTL value into duration in seconds.
protected
duration(int|DateInterval $ttl) : int
Parameters
- $ttl : int|DateInterval
Return values
intgetFilePathname()
Returns cache file pathname from key.
private
getFilePathname(string $key) : string
Parameters
- $key : string
Return values
stringprune()
Removes previous cache files.
private
prune(string $key) : bool
Parameters
- $key : string