FileStorage
extends BaseStorage
in package
Cache storage in the filesystem.
Tags
Table of Contents
- GC_FILE = 'horde_cache_gc'
- $file : array<string|int, mixed>
- List of key to filename mappings.
- $logger : Horde_Log_Logger|null
- Logger.
- $params : array<string|int, mixed>
- Parameters.
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Destructor.
- __serialize() : array<string|int, mixed>
- __unserialize() : void
- clear() : mixed
- Clears all data from the cache.
- exists() : bool
- Checks if a given key exists in the cache, valid for the given lifetime.
- expire() : bool
- Expire any existing data for the given key.
- get() : mixed
- Retrieve cached data.
- serialize() : string
- set() : mixed
- Store an object in the cache.
- setLogger() : void
- Set the logging object.
- unserialize() : mixed
- _gc() : mixed
- Garbage collector.
- _getCacheFiles() : array<string|int, mixed>
- Return a list of cache files.
- _getGCFiles() : array<string|int, mixed>
- Return a list of GC indexes.
- _initOb() : mixed
- Do initialization tasks.
- _keyToFile() : string
- Map a cache key to a unique filename.
- _migrateGc() : mixed
- Migrates single GC indexes to per-directory indexes.
Constants
GC_FILE
public
mixed
GC_FILE
= 'horde_cache_gc'
Properties
$file
List of key to filename mappings.
protected
array<string|int, mixed>
$file
= []
$logger
Logger.
protected
Horde_Log_Logger|null
$logger
$params
Parameters.
protected
array<string|int, mixed>
$params
= []
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $params = [] ]) : mixed
Parameters
- $params : array<string|int, mixed> = []
-
Optional parameters:
- dir: (string) The base directory to store the cache files in. DEFAULT: System default - no_gc: (boolean) If true, don't perform garbage collection. DEFAULT: false - prefix: (string) The filename prefix to use for the cache files. DEFAULT: 'cache_' - sub: (integer) If non-zero, the number of subdirectories to create to store the file (i.e. PHP's session.save_path). DEFAULT: 0
Return values
mixed —__destruct()
Destructor.
public
__destruct() : mixed
Return values
mixed —__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Return values
void —clear()
Clears all data from the cache.
public
clear() : mixed
Tags
Return values
mixed —exists()
Checks if a given key exists in the cache, valid for the given lifetime.
public
exists(mixed $key, mixed $lifetime) : bool
Parameters
- $key : mixed
-
Cache key to check.
- $lifetime : mixed
-
Lifetime of the key in seconds.
Tags
Return values
bool —Existence.
expire()
Expire any existing data for the given key.
public
expire(string $key) : bool
Parameters
- $key : string
-
Cache key to expire.
Tags
Return values
bool —Success or failure.
get()
Retrieve cached data.
public
get(string $key, int $lifetime) : mixed
Parameters
- $key : string
-
Object ID to query.
- $lifetime : int
-
Lifetime of the object in seconds.
Tags
Return values
mixed —Cached data, or false if none was found.
serialize()
public
serialize() : string
Return values
string —set()
Store an object in the cache.
public
set(string $key, mixed $data, int $lifetime) : mixed
Parameters
- $key : string
-
Object ID used as the caching key.
- $data : mixed
-
Data to store in the cache.
- $lifetime : int
-
Object lifetime - i.e. the time before the data becomes available for garbage collection. If 0 will not be GC'd.
Tags
Return values
mixed —setLogger()
Set the logging object.
public
setLogger(Horde_Log_Logger $logger) : void
Parameters
- $logger : Horde_Log_Logger
-
Log object.
Return values
void —unserialize()
public
unserialize(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —_gc()
Garbage collector.
protected
_gc() : mixed
Return values
mixed —_getCacheFiles()
Return a list of cache files.
protected
_getCacheFiles([string $start = null ]) : array<string|int, mixed>
Parameters
- $start : string = null
-
The directory to start searching.
Return values
array<string|int, mixed> —Pathnames to cache files.
_getGCFiles()
Return a list of GC indexes.
protected
_getGCFiles() : array<string|int, mixed>
Return values
array<string|int, mixed> —Pathnames to GC indexes.
_initOb()
Do initialization tasks.
protected
_initOb() : mixed
Return values
mixed —_keyToFile()
Map a cache key to a unique filename.
protected
_keyToFile(string $key[, string|bool $create = false ]) : string
Parameters
- $key : string
-
Cache key.
- $create : string|bool = false
-
Create path if it doesn't exist?
Return values
string —Fully qualified filename.
_migrateGc()
Migrates single GC indexes to per-directory indexes.
protected
_migrateGc() : mixed