class FileStorage implements Storage

Cache file storage.

Constants

private internal MetaHeaderLen

private internal MetaTime

private internal MetaSerialized

private internal MetaExpire

private internal MetaDelta

private internal MetaItems

private internal MetaCallbacks

private File

additional cache structure

private Handle

additional cache structure

Properties

static $gcProbability

Probability (0-1) that the garbage collector runs on each instantiation.

Methods

__construct(string $dir, Journal|null $journal = null)

No description

mixed
read(string $key)

Reads item from the cache. Returns null if the item does not exist or has expired.

void
lock(string $key)

Prevents item reading and writing. Lock is released by write() or remove().

void
write(string $key, mixed $data, array $dp)

No description

void
remove(string $key)

Removes item from the cache.

void
clean(array $conditions)

No description

array|null
readMetaAndLock(string $file, int $lock)

Opens and locks a cache file and reads its metadata.

mixed
readData(array $meta)

Reads cache data from disk and closes cache file handle.

string
getCacheFile(string $key)

Returns the file path for a given cache key.

Details

at line 58
__construct(string $dir, Journal|null $journal = null)

No description

Parameters

string $dir
Journal|null $journal

at line 73
mixed read(string $key)

Reads item from the cache. Returns null if the item does not exist or has expired.

Parameters

string $key

Return Value

mixed

at line 122
void lock(string $key)

Prevents item reading and writing. Lock is released by write() or remove().

Parameters

string $key

Return Value

void

at line 140
void write(string $key, mixed $data, array $dp)

No description

Parameters

string $key
mixed $data
array $dp

Return Value

void

at line 221
void remove(string $key)

Removes item from the cache.

Parameters

string $key

Return Value

void

at line 229
void clean(array $conditions)

No description

Parameters

array $conditions

Return Value

void

at line 301
protected array|null readMetaAndLock(string $file, int $lock)

Opens and locks a cache file and reads its metadata.

Parameters

string $file
int $lock

Return Value

array|null

meta data with 'file' and 'handle' keys added, or null if not found

at line 332
protected mixed readData(array $meta)

Reads cache data from disk and closes cache file handle.

Parameters

array $meta

Return Value

mixed

at line 348
protected string getCacheFile(string $key)

Returns the file path for a given cache key.

Parameters

string $key

Return Value

string