FileCache
extends AbstractCache
in package
Cache class for PSR-16 compatible "Simple Cache" implementation using file backend.
Defaults to 1 year TTL. Does not support unlimited TTL.
Table of Contents
Properties
- $defaultLifetime : int|null
- $directory : string
- $miss : stdClass
- $namespace : string
- $tmp : string|null
- $validation : bool
Methods
- __construct() : mixed
- FileCache constructor.
- __destruct() : void
- clear() : bool
- delete() : bool
- deleteMultiple() : bool
- doClear() : bool
- doDelete() : mixed
- doDeleteMultiple() : bool
- doGet() : mixed
- doGetMultiple() : array<string|int, mixed>
- doHas() : mixed
- doSet() : mixed
- doSetMultiple() : bool
- get() : mixed|null
- getMultiple() : iterable<string|int, mixed>
- has() : bool
- set() : bool
- setMultiple() : bool
- setValidation() : void
- convertTtl() : int|null
- getDefaultLifetime() : int|null
- getFile() : string
- getNamespace() : string
- init() : void
- Always call from constructor.
- initFileCache() : void
- validateKey() : void
- validateKeys() : void
- mkdir() : void
- write() : bool
Properties
$defaultLifetime
private
int|null
$defaultLifetime
= null
$directory
private
string
$directory
$miss
private
stdClass
$miss
$namespace
private
string
$namespace
= ''
$tmp
private
string|null
$tmp
$validation
private
bool
$validation
= true
Methods
__construct()
FileCache constructor.
public
__construct([string $namespace = '' ][, int|null $defaultLifetime = null ][, string|null $folder = null ]) : mixed
Parameters
- $namespace : string = ''
- $defaultLifetime : int|null = null
- $folder : string|null = null
Tags
__destruct()
public
__destruct() : void
Attributes
- #[ReturnTypeWillChange]
clear()
public
clear() : bool
Return values
booldelete()
public
delete(string $key) : bool
Parameters
- $key : string
Tags
Return values
booldeleteMultiple()
public
deleteMultiple(iterable<string|int, mixed> $keys) : bool
Parameters
- $keys : iterable<string|int, mixed>
Tags
Return values
booldoClear()
public
doClear() : bool
Tags
Return values
booldoDelete()
public
doDelete(mixed $key) : mixed
Parameters
- $key : mixed
Tags
doDeleteMultiple()
public
doDeleteMultiple(array<string|int, mixed> $keys) : bool
Parameters
- $keys : array<string|int, mixed>
Return values
booldoGet()
public
doGet(mixed $key, mixed $miss) : mixed
Parameters
- $key : mixed
- $miss : mixed
Tags
doGetMultiple()
public
doGetMultiple(array<string|int, mixed> $keys, mixed $miss) : array<string|int, mixed>
Parameters
- $keys : array<string|int, mixed>
- $miss : mixed
Return values
array<string|int, mixed>doHas()
public
doHas(mixed $key) : mixed
Parameters
- $key : mixed
Tags
doSet()
public
doSet(mixed $key, mixed $value, mixed $ttl) : mixed
Parameters
- $key : mixed
- $value : mixed
- $ttl : mixed
Tags
doSetMultiple()
public
doSetMultiple(array<string|int, mixed> $values, int|null $ttl) : bool
Parameters
- $values : array<string|int, mixed>
- $ttl : int|null
Return values
boolget()
public
get(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
- $key : string
- $default : mixed|null = null
Tags
Return values
mixed|nullgetMultiple()
public
getMultiple(iterable<string|int, mixed> $keys[, mixed|null $default = null ]) : iterable<string|int, mixed>
Parameters
- $keys : iterable<string|int, mixed>
- $default : mixed|null = null
Tags
Return values
iterable<string|int, mixed>has()
public
has(string $key) : bool
Parameters
- $key : string
Tags
Return values
boolset()
public
set(string $key, mixed $value[, null|int|DateInterval $ttl = null ]) : bool
Parameters
- $key : string
- $value : mixed
- $ttl : null|int|DateInterval = null
Tags
Return values
boolsetMultiple()
public
setMultiple(iterable<string|int, mixed> $values[, null|int|DateInterval $ttl = null ]) : bool
Parameters
- $values : iterable<string|int, mixed>
- $ttl : null|int|DateInterval = null
Tags
Return values
boolsetValidation()
public
setValidation(bool $validation) : void
Parameters
- $validation : bool
convertTtl()
protected
convertTtl(null|int|DateInterval $ttl) : int|null
Parameters
- $ttl : null|int|DateInterval
Tags
Return values
int|nullgetDefaultLifetime()
protected
getDefaultLifetime() : int|null
Return values
int|nullgetFile()
protected
getFile(string $key[, bool $mkdir = false ]) : string
Parameters
- $key : string
- $mkdir : bool = false
Return values
stringgetNamespace()
protected
getNamespace() : string
Return values
stringinit()
Always call from constructor.
protected
init([string $namespace = '' ][, null|int|DateInterval $defaultLifetime = null ]) : void
Parameters
- $namespace : string = ''
- $defaultLifetime : null|int|DateInterval = null
Tags
initFileCache()
protected
initFileCache(string $namespace, string $directory) : void
Parameters
- $namespace : string
- $directory : string
Tags
validateKey()
protected
validateKey(string|mixed $key) : void
Parameters
- $key : string|mixed
Tags
validateKeys()
protected
validateKeys(array<string|int, mixed> $keys) : void
Parameters
- $keys : array<string|int, mixed>
Tags
mkdir()
private
mkdir(string $dir) : void
Parameters
- $dir : string
Tags
write()
private
write(string $file, string $data[, int|null $expiresAt = null ]) : bool
Parameters
- $file : string
- $data : string
- $expiresAt : int|null = null