interface FileCache

Methods

mixed
get(File $file, callable $callback, bool $throwOnLock)

Perform a callback with the path of a cached file. This takes care of shared locks on the cached file file so it is not corrupted due to concurrent write operations.

mixed
getOnce(File $file, callable $callback, bool $throwOnLock)

Like get but deletes the cached file afterwards (if it is not used somewhere else).

resource
getStream(File $file)

Get a stream resource for an file. If the file is cached, the resource points to the cached file instead. This will not cache uncached files. Make sure to close the streams!

mixed
batch(array $files, callable $callback, bool $throwOnLock)

Perform a callback with the paths of many cached files. Use this to prevent pruning of the files while they are processed.

mixed
batchOnce(array $files, callable $callback, bool $throwOnLock)

Like batch but deletes the cached files afterwards (if they are not used somewhere else).

prune()

Remove cached files that are too old or exceed the maximum cache size.

clear()

Delete all unused cached files.

bool
exists(File $file)

Check if a file exists.

Details

at line 19
mixed get(File $file, callable $callback, bool $throwOnLock)

Perform a callback with the path of a cached file. This takes care of shared locks on the cached file file so it is not corrupted due to concurrent write operations.

Parameters

File $file
callable $callback

Gets the file object and the path to the cached file file as arguments.

bool $throwOnLock

Whether to throw an exception if a file is currently locked (i.e. written to). Otherwise the method will wait until the lock is released.

Return Value

mixed

Result of the callback.

at line 32
mixed getOnce(File $file, callable $callback, bool $throwOnLock)

Like get but deletes the cached file afterwards (if it is not used somewhere else).

Parameters

File $file
callable $callback

Gets the file object and the path to the cached file file as arguments.

bool $throwOnLock

Whether to throw an exception if a file is currently locked (i.e. written to). Otherwise the method will wait until the lock is released.

Return Value

mixed

Result of the callback.

at line 44
resource getStream(File $file)

Get a stream resource for an file. If the file is cached, the resource points to the cached file instead. This will not cache uncached files. Make sure to close the streams!

Parameters

File $file

Return Value

resource

Exceptions

Exception

at line 57
mixed batch(array $files, callable $callback, bool $throwOnLock)

Perform a callback with the paths of many cached files. Use this to prevent pruning of the files while they are processed.

Parameters

array $files
callable $callback

Gets the array of file objects and the array of paths to the cached file files (in the same ordering) as arguments.

bool $throwOnLock

Whether to throw an exception if a file is currently locked (i.e. written to). Otherwise the method will wait until the lock is released.

Return Value

mixed

Result of the callback.

at line 70
mixed batchOnce(array $files, callable $callback, bool $throwOnLock)

Like batch but deletes the cached files afterwards (if they are not used somewhere else).

Parameters

array $files
callable $callback

Gets the array of file objects and the array of paths to the cached file files (in the same ordering) as arguments.

bool $throwOnLock

Whether to throw an exception if a file is currently locked (i.e. written to). Otherwise the method will wait until the lock is released.

Return Value

mixed

Result of the callback.

at line 75
prune()

Remove cached files that are too old or exceed the maximum cache size.

at line 80
clear()

Delete all unused cached files.

at line 89
bool exists(File $file)

Check if a file exists.

Parameters

File $file

Return Value

bool

Whether the file exists or not.