FileCacheStorage
in package
implements
ICacheStorage
Table of Contents
Interfaces
Properties
- $_BasePath : string
- $clock : IClock
- $fs : IFileSystem
Methods
- __construct() : mixed
- FileCacheStorage constructor
- clear() : bool
- Clear all cache entries
- delete() : bool
- Delete cache entry
- exists() : bool
- Check if cache key exists
- gc() : int
- Run garbage collection to remove expired cache entries
- isExpired() : bool
- Check if cache entry is expired
- read() : string|null
- Read content from cache
- write() : bool
- Write content to cache
- ensureDirectoryExists() : void
- Ensure directory exists
- getFilePath() : string
- Get file path for cache key
- getMetaPath() : string
- Get metadata file path for cache key
- recursiveDelete() : bool
- Recursively delete directory contents
- scanAndClean() : void
- Scan directory and clean expired entries
Properties
$_BasePath
private
string
$_BasePath
$clock
private
IClock
$clock
$fs
private
IFileSystem
$fs
Methods
__construct()
FileCacheStorage constructor
public
__construct(string $BasePath[, IFileSystem|null $fs = null ][, IClock|null $clock = null ]) : mixed
Parameters
- $BasePath : string
- $fs : IFileSystem|null = null
-
File system implementation (null = use real file system)
- $clock : IClock|null = null
-
Clock implementation (null = use real clock)
Tags
clear()
Clear all cache entries
public
clear() : bool
Return values
booldelete()
Delete cache entry
public
delete(string $Key) : bool
Parameters
- $Key : string
Return values
boolexists()
Check if cache key exists
public
exists(string $Key) : bool
Parameters
- $Key : string
Return values
boolgc()
Run garbage collection to remove expired cache entries
public
gc() : int
Return values
int —Number of entries removed
isExpired()
Check if cache entry is expired
public
isExpired(string $Key) : bool
Parameters
- $Key : string
Return values
boolread()
Read content from cache
public
read(string $Key) : string|null
Parameters
- $Key : string
Return values
string|nullwrite()
Write content to cache
public
write(string $Key, string $Content, int $Ttl) : bool
Parameters
- $Key : string
- $Content : string
- $Ttl : int
Tags
Return values
boolensureDirectoryExists()
Ensure directory exists
private
ensureDirectoryExists(string $Path) : void
Parameters
- $Path : string
Tags
getFilePath()
Get file path for cache key
private
getFilePath(string $Key) : string
Parameters
- $Key : string
Return values
stringgetMetaPath()
Get metadata file path for cache key
private
getMetaPath(string $Key) : string
Parameters
- $Key : string
Return values
stringrecursiveDelete()
Recursively delete directory contents
private
recursiveDelete(string $Path[, bool $DeleteSelf = true ]) : bool
Parameters
- $Path : string
- $DeleteSelf : bool = true
Return values
boolscanAndClean()
Scan directory and clean expired entries
private
scanAndClean(string $Dir, int &$Count) : void
Parameters
- $Dir : string
- $Count : int