FileCache
class FileCache implements FileCache
The file cache.
Properties
protected array | $config | File cache configuration. |
|
protected Filesystem | $files | The Filesytem instance to use |
|
protected FilesystemManager | $storage | File FilesystemManager instance to use |
|
protected ClientInterface | $client | Guzzle HTTP client to use |
Methods
Create an instance.
Perform a callback with the paths of many cached files. Use this to prevent pruning of the files while they are processed.
Like batch
but deletes the cached files afterwards (if they are not used
somewhere else).
Remove cached files that are too old or exceed the maximum cache size.
Delete all unused cached files.
Get path and handle for a file that exists in the cache.
Get path and handle for a file that does not yet exist in the cache.
Cache an file from a storage disk and get the path to the cached file. Files from local disks are not cached.
Store the file from the given resource to a cached file.
Creates the cache directory if it doesn't exist yet.
Get the stream resource for an file.
Create a new Guzzle HTTP client.
Details
at line 58
__construct(array $config = [], Filesystem $files = null, FilesystemManager $storage = null, $client = null)
Create an instance.
at line 69
bool
exists(File $file)
Check if a file exists.
at line 81
mixed
get(File $file, callable $callback, bool $throwOnLock = false)
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.
at line 91
mixed
getOnce(File $file, callable $callback, bool $throwOnLock = false)
Like get
but deletes the cached file afterwards (if it is not used somewhere
else).
at line 101
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!
at line 133
mixed
batch(array $files, callable $callback, bool $throwOnLock = false)
Perform a callback with the paths of many cached files. Use this to prevent pruning of the files while they are processed.
at line 157
mixed
batchOnce(array $files, callable $callback, bool $throwOnLock = false)
Like batch
but deletes the cached files afterwards (if they are not used
somewhere else).
at line 191
prune()
Remove cached files that are too old or exceed the maximum cache size.
at line 270
clear()
Delete all unused cached files.
at line 294
protected bool
existsRemote(File $file)
Check for existence of a remte file.
at line 328
protected bool
existsDisk(File $file)
Check for existence of a file from a storage disk.
at line 363
protected bool
delete(SplFileInfo $file)
Delete a cached file it it is not used.
at line 395
protected array
retrieve(File $file, bool $throwOnLock = false)
Cache a remote or cloud storage file if it is not cached and get the path to the cached file. If the file is local, nothing will be done and the path to the local file will be returned.
at line 461
protected array
retrieveExistingFile(string $cachedPath, resource $handle)
Get path and handle for a file that exists in the cache.
at line 482
protected array
retrieveNewFile(File $file, string $cachedPath, resource $handle)
Get path and handle for a file that does not yet exist in the cache.
at line 525
protected string
getDiskFile(File $file, resource $target)
Cache an file from a storage disk and get the path to the cached file. Files from local disks are not cached.
at line 553
protected string
cacheFromResource(File $file, resource $source, resource $target)
Store the file from the given resource to a cached file.
at line 583
protected
ensurePathExists()
Creates the cache directory if it doesn't exist yet.
at line 597
protected string
getCachedPath(File $file)
Get the path to the cached file file.
at line 611
protected resource
getFileStream(string $url)
Get the stream resource for an file.
at line 627
protected bool
isRemote(File $file)
Determine if an file is remote, i.e. served by a public webserver.
at line 639
protected Filesystem
getDisk(File $file)
Get the storage disk on which a file is stored.
at line 652
protected ClientInterface
makeHttpClient()
Create a new Guzzle HTTP client.