Kotchasan

FileCache extends Cache
in package

This class provides functionality for caching data to the filesystem.

Tags
see
https://www.kotchasan.com/

Table of Contents

$cache_dir  : string
Cache directory path
$cache_expire  : int
Cache expiration time in seconds (0 means no cache)
$cfg  : object
Config class instance.
$deferred  : array<string|int, mixed>
Deferred cache items
$request  : Request
Server request class instance.
__construct()  : mixed
Class constructor
clear()  : bool
Clear the cache
commit()  : bool
Commit the cached items in the deferred queue
deleteItem()  : bool
Delete a cache item
deleteItems()  : bool
Delete multiple cache items
getItem()  : CacheItemInterface
Get a cache item
getItems()  : array<string|int, mixed>
Get multiple cache items
hasItem()  : bool
Check if a cache item exists
save()  : bool
Save a cache item
saveDeferred()  : bool
Save a cache item for deferred saving
clearCache()  : mixed
Clear all files in the cache directory
fetchStreamUri()  : string
Get the full path of the cache file
isExpired()  : bool
Check if a cache file has expired

Properties

$cache_dir

Cache directory path

protected string $cache_dir = null

/root/to/dir/cache/

$cache_expire

Cache expiration time in seconds (0 means no cache)

protected int $cache_expire = 0

$cfg

Config class instance.

protected static object $cfg

$deferred

Deferred cache items

protected array<string|int, mixed> $deferred = []

$request

Server request class instance.

protected static Request $request

Methods

__construct()

Class constructor

public __construct() : mixed
Tags
throws
Exception

if the cache directory cannot be created

Return values
mixed

clear()

Clear the cache

public clear() : bool
Return values
bool

true if the cache is cleared successfully, false otherwise

commit()

Commit the cached items in the deferred queue

public commit() : bool
Return values
bool

deleteItem()

Delete a cache item

public deleteItem(string $key) : bool
Parameters
$key : string
Return values
bool

deleteItems()

Delete multiple cache items

public deleteItems(array<string|int, mixed> $keys) : bool
Parameters
$keys : array<string|int, mixed>
Return values
bool

true if the deletion is successful, false otherwise

getItems()

Get multiple cache items

public getItems([array<string|int, mixed> $keys = [] ]) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed> = []
Return values
array<string|int, mixed>

hasItem()

Check if a cache item exists

public hasItem(string $key) : bool
Parameters
$key : string
Return values
bool

clearCache()

Clear all files in the cache directory

private clearCache(string $dir, array<string|int, mixed> &$error) : mixed
Parameters
$dir : string
$error : array<string|int, mixed>
Return values
mixed

fetchStreamUri()

Get the full path of the cache file

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

isExpired()

Check if a cache file has expired

private isExpired(string $file) : bool
Parameters
$file : string
Return values
bool

Search results