Neuron-PHP

FileCacheStorage
in package
implements ICacheStorage

Table of Contents

Interfaces

ICacheStorage

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

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
throws
CacheException

clear()

Clear all cache entries

public clear() : bool
Return values
bool

delete()

Delete cache entry

public delete(string $Key) : bool
Parameters
$Key : string
Return values
bool

exists()

Check if cache key exists

public exists(string $Key) : bool
Parameters
$Key : string
Return values
bool

gc()

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
bool

read()

Read content from cache

public read(string $Key) : string|null
Parameters
$Key : string
Return values
string|null

write()

Write content to cache

public write(string $Key, string $Content, int $Ttl) : bool
Parameters
$Key : string
$Content : string
$Ttl : int
Tags
throws
CacheException
Return values
bool

ensureDirectoryExists()

Ensure directory exists

private ensureDirectoryExists(string $Path) : void
Parameters
$Path : string
Tags
throws
CacheException

getFilePath()

Get file path for cache key

private getFilePath(string $Key) : string
Parameters
$Key : string
Return values
string

getMetaPath()

Get metadata file path for cache key

private getMetaPath(string $Key) : string
Parameters
$Key : string
Return values
string

recursiveDelete()

Recursively delete directory contents

private recursiveDelete(string $Path[, bool $DeleteSelf = true ]) : bool
Parameters
$Path : string
$DeleteSelf : bool = true
Return values
bool

scanAndClean()

Scan directory and clean expired entries

private scanAndClean(string $Dir, int &$Count) : void
Parameters
$Dir : string
$Count : int

        
On this page

Search results