Cecil

Cache implements CacheInterface

Cache class.

Provides methods to manage cache files for assets, pages, and other data.

Table of Contents

Interfaces

CacheInterface

Properties

$builder  : Builder
$cacheDir  : string

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

$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
bool

clearByPattern()

Clear cache by pattern.

public clearByPattern(string $pattern) : int
Parameters
$pattern : string
Return values
int

createKey()

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
string

createKeyFromAsset()

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
string

createKeyFromFile()

Creates key from a file: "RelativePathname__MD5".

public createKeyFromFile(SplFileInfo $file) : string
Parameters
$file : SplFileInfo
Tags
throws
RuntimeException
Return values
string

createKeyFromValue()

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
string

delete()

{@inheritdoc}

public delete(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

deleteMultiple()

{@inheritdoc}

public deleteMultiple(mixed $keys) : bool
Parameters
$keys : mixed
Return values
bool

get()

{@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
string

getMultiple()

{@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
bool

sanitizeKey()

Prepares and validate $key.

public static sanitizeKey(string $key) : string
Parameters
$key : string
Return values
string

set()

{@inheritdoc}

public set(mixed $key, mixed $value[, mixed $ttl = null ]) : bool
Parameters
$key : mixed
$value : mixed
$ttl : mixed = null
Return values
bool

setMultiple()

{@inheritdoc}

public setMultiple(mixed $values[, mixed $ttl = null ]) : bool
Parameters
$values : mixed
$ttl : mixed = null
Return values
bool

deleteContentFile()

Removes the cache content file.

protected deleteContentFile(string $path) : bool
Parameters
$path : string
Return values
bool

duration()

Convert the various expressions of a TTL value into duration in seconds.

protected duration(int|DateInterval $ttl) : int
Parameters
$ttl : int|DateInterval
Return values
int

getFilePathname()

Returns cache file pathname from key.

private getFilePathname(string $key) : string
Parameters
$key : string
Return values
string

prune()

Removes previous cache files.

private prune(string $key) : bool
Parameters
$key : string
Return values
bool
 
On this page

Search results