\Horde_Cache_Storage_File

Cache storage in the filesystem.

Summary

Methods
Properties
Constants
__construct()
setLogger()
get()
set()
exists()
expire()
clear()
serialize()
unserialize()
__destruct()
No public properties found
GC_FILE
_initOb()
_getCacheFiles()
_getGCFiles()
_keyToFile()
_gc()
_migrateGc()
$_logger
$_params
$_file
N/A
No private methods found
No private properties found
N/A

Constants

GC_FILE

GC_FILE

Properties

$_logger

$_logger : \Horde_Log_Logger

Logger.

Type

\Horde_Log_Logger

$_params

$_params : array

Parameters.

Type

array

$_file

$_file : array

List of key to filename mappings.

Type

array

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

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

setLogger()

setLogger(\Horde_Log_Logger  $logger) 

Set the logging object.

Parameters

\Horde_Log_Logger $logger

Log object.

get()

get(string  $key, integer  $lifetime) : mixed

Retrieve cached data.

Parameters

string $key

Object ID to query.

integer $lifetime

Lifetime of the object in seconds.

Returns

mixed —

Cached data, or false if none was found.

set()

set(string  $key, mixed  $data, integer  $lifetime) 

Store an object in the cache.

Parameters

string $key

Object ID used as the caching key.

mixed $data

Data to store in the cache.

integer $lifetime

Object lifetime - i.e. the time before the data becomes available for garbage collection. If 0 will not be GC'd.

exists()

exists(string  $key, integer  $lifetime) : boolean

Checks if a given key exists in the cache, valid for the given lifetime.

Parameters

string $key

Cache key to check.

integer $lifetime

Lifetime of the key in seconds.

Returns

boolean —

Existence.

expire()

expire(string  $key) : boolean

Expire any existing data for the given key.

Parameters

string $key

Cache key to expire.

Returns

boolean —

Success or failure.

clear()

clear() 

Clears all data from the cache.

serialize()

serialize() 

unserialize()

unserialize(  $data) 

Parameters

$data

__destruct()

__destruct() 

Destructor.

_initOb()

_initOb() 

Do initialization tasks.

_getCacheFiles()

_getCacheFiles(string  $start = null) : array

Return a list of cache files.

Parameters

string $start

The directory to start searching.

Returns

array —

Pathnames to cache files.

_getGCFiles()

_getGCFiles() : array

Return a list of GC indexes.

Returns

array —

Pathnames to GC indexes.

_keyToFile()

_keyToFile(string  $key, string  $create = false) : string

Map a cache key to a unique filename.

Parameters

string $key

Cache key.

string $create

Create path if it doesn't exist?

Returns

string —

Fully qualified filename.

_gc()

_gc() 

Garbage collector.

_migrateGc()

_migrateGc() 

Migrates single GC indexes to per-directory indexes.