Aplus Framework Docs

FilesCache extends Cache
in package

Class FilesCache.

Table of Contents

$defaultTtl  : int
The default Time To Live value.
$baseDirectory  : string|null
$configs  : array<string|int, mixed>
Files Cache handler configurations.
$debugCollector  : CacheCollector
$logger  : Logger|null
The Logger instance if is set.
$prefix  : string|null
Keys prefix.
$serializer  : Serializer
Data serializer.
__construct()  : mixed
Cache constructor.
__destruct()  : mixed
decrement()  : int
Decrements the value of one item.
delete()  : bool
Deletes one item from the cache storage.
deleteMulti()  : array<string, bool>
Deletes multi items from the cache storage.
flush()  : bool
Flush the cache storage.
gc()  : bool
Garbage collector.
get()  : mixed
Gets one item from the cache storage.
getMulti()  : array<string, mixed>
Gets multi items from the cache storage.
increment()  : int
Increments the value of one item.
set()  : bool
Sets one item to the cache storage.
setDebugCollector()  : static
setMulti()  : array<string, bool>
Sets multi items to the cache storage.
setValue()  : bool
addDebugDelete()  : bool
addDebugFlush()  : bool
addDebugGet()  : mixed
addDebugSet()  : bool
closeDir()  : void
createSubDirectory()  : void
deleteAll()  : bool
deleteExpired()  : bool
deleteFile()  : bool
getContents()  : mixed
initialize()  : void
Initialize Cache handlers and configurations.
log()  : void
makeTtl()  : int
Make the Time To Live value.
openDir()  : false|resource
renderFilepath()  : string
renderKey()  : string
serialize()  : string
setBaseDirectory()  : void
setGC()  : void
unserialize()  : mixed

Properties

$defaultTtl

The default Time To Live value.

public int $defaultTtl = 60

Used when set methods has the $ttl param as null.

$baseDirectory

protected string|null $baseDirectory

$configs

Files Cache handler configurations.

protected array<string|int, mixed> $configs = ['directory' => null, 'files_permission' => 0644, 'gc' => 1]

$logger

The Logger instance if is set.

protected Logger|null $logger

$prefix

Keys prefix.

protected string|null $prefix

Methods

__construct()

Cache constructor.

public __construct([array<string, mixed>|null $configs = [] ][, string|null $prefix = null ][, Serializer $serializer = Serializer::PHP ][, Logger $logger = null ]) : mixed
Parameters
$configs : array<string, mixed>|null = []

Driver specific configurations. Set null to not initialize and set a custom object.

$prefix : string|null = null

Keys prefix

$serializer : Serializer = Serializer::PHP

Data serializer

$logger : Logger = null
Return values
mixed

__destruct()

public __destruct() : mixed
Return values
mixed

decrement()

Decrements the value of one item.

public decrement(string $key[, int $offset = 1 ][, int|null $ttl = null ]) : int
Parameters
$key : string

The item name

$offset : int = 1

The value to decrement

$ttl : int|null = null

The Time To Live for the item or null to use the default

Return values
int

The current item value

delete()

Deletes one item from the cache storage.

public delete(string $key) : bool
Parameters
$key : string

the item name

Return values
bool

TRUE if the item was deleted, FALSE if fail to delete

deleteMulti()

Deletes multi items from the cache storage.

public deleteMulti(array<int, string> $keys) : array<string, bool>
Parameters
$keys : array<int, string>

List of items names to be deleted

Return values
array<string, bool>

associative array with key names and respective delete status

flush()

Flush the cache storage.

public flush() : bool
Return values
bool

TRUE if all items are deleted, otherwise FALSE

gc()

Garbage collector.

public gc() : bool

Deletes all expired items.

Return values
bool

TRUE if all expired items was deleted, FALSE if a fail occurs

get()

Gets one item from the cache storage.

public get(string $key) : mixed
Parameters
$key : string

The item name

Return values
mixed

The item value or null if not found

getMulti()

Gets multi items from the cache storage.

public getMulti(array<int, string> $keys) : array<string, mixed>
Parameters
$keys : array<int, string>

List of items names to get

Return values
array<string, mixed>

associative array with key names and respective values

increment()

Increments the value of one item.

public increment(string $key[, int $offset = 1 ][, int|null $ttl = null ]) : int
Parameters
$key : string

The item name

$offset : int = 1

The value to increment

$ttl : int|null = null

The Time To Live for the item or null to use the default

Return values
int

The current item value

set()

Sets one item to the cache storage.

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

The item name

$value : mixed

The item value

$ttl : int = null

The Time To Live for the item or null to use the default

Return values
bool

TRUE if the item was set, FALSE if fail to set

setMulti()

Sets multi items to the cache storage.

public setMulti(array<string, mixed> $data[, int|null $ttl = null ]) : array<string, bool>
Parameters
$data : array<string, mixed>

Associative array with key names and respective values

$ttl : int|null = null

The Time To Live for all the items or null to use the default

Return values
array<string, bool>

associative array with key names and respective set status

setValue()

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

addDebugDelete()

protected addDebugDelete(string $key, float $start, bool $status) : bool
Parameters
$key : string
$start : float
$status : bool
Return values
bool

addDebugFlush()

protected addDebugFlush(float $start, bool $status) : bool
Parameters
$start : float
$status : bool
Return values
bool

addDebugGet()

protected addDebugGet(string $key, float $start, mixed $value) : mixed
Parameters
$key : string
$start : float
$value : mixed
Return values
mixed

addDebugSet()

protected addDebugSet(string $key, int|null $ttl, float $start, mixed $value, bool $status) : bool
Parameters
$key : string
$ttl : int|null
$start : float
$value : mixed
$status : bool
Return values
bool

closeDir()

protected closeDir(resource $resource) : void
Parameters
$resource : resource
Return values
void

createSubDirectory()

protected createSubDirectory(string $filepath) : void
Parameters
$filepath : string
Return values
void

deleteAll()

protected deleteAll(string $baseDirectory) : bool
Parameters
$baseDirectory : string
Return values
bool

deleteExpired()

protected deleteExpired(string $baseDirectory) : bool
Parameters
$baseDirectory : string
Return values
bool

deleteFile()

protected deleteFile(string $filepath) : bool
Parameters
$filepath : string
Return values
bool

getContents()

protected getContents(string $filepath) : mixed
Parameters
$filepath : string
Return values
mixed

initialize()

Initialize Cache handlers and configurations.

protected initialize() : void
Return values
void

log()

protected log(string $message[, LogLevel $level = LogLevel::ERROR ]) : void
Parameters
$message : string
$level : LogLevel = LogLevel::ERROR
Return values
void

makeTtl()

Make the Time To Live value.

protected makeTtl(int|null $seconds) : int
Parameters
$seconds : int|null

TTL value or null to use the default

Return values
int

The input $seconds or the $defaultTtl as integer

openDir()

protected openDir(string $dirpath) : false|resource
Parameters
$dirpath : string
Return values
false|resource

renderFilepath()

protected renderFilepath(string $key) : string
Parameters
$key : string
Return values
string

renderKey()

protected renderKey(string $key) : string
Parameters
$key : string
Return values
string

serialize()

protected serialize(mixed $value) : string
Parameters
$value : mixed
Tags
throws
JsonException
Return values
string

setBaseDirectory()

protected setBaseDirectory() : void
Return values
void

setGC()

protected setGC(int $gc) : void
Parameters
$gc : int
Return values
void

unserialize()

protected unserialize(string $value) : mixed
Parameters
$value : string
Return values
mixed

Search results