\Horde_Cache_Storage_Sql

Cache storage in a SQL databsae.

The table structure for the cache is as follows:

CREATE TABLE horde_cache (
    cache_id          VARCHAR(32) NOT NULL,
    cache_timestamp   BIGINT NOT NULL,
    cache_data        LONGBLOB,
    (Or on PostgreSQL:)
    cache_data        TEXT,
    (Or on some other DBMS systems:)
    cache_data        IMAGE,

    PRIMARY KEY (cache_id)
);

Summary

Methods
Properties
Constants
__construct()
setLogger()
get()
set()
exists()
expire()
clear()
serialize()
unserialize()
__destruct()
No public properties found
No constants found
_initOb()
$_logger
$_params
$_db
N/A
No private methods found
No private properties found
N/A

Properties

$_logger

$_logger : \Horde_Log_Logger

Logger.

Type

\Horde_Log_Logger

$_params

$_params : array

Parameters.

Type

array

$_db

$_db : \Horde_Db_Adapter

Handle for the current database connection.

Type

\Horde_Db_Adapter

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Parameters:

  - db: (Horde_Db_Adapter) [REQUIRED] The DB instance.
  - table: (string) The name of the cache table.
           DEFAULT: 'horde_cache'

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.