Class Horde_Cache_sql

Description

The Horde_Cache_sql:: class provides a SQL implementation of the Horde Caching system.

Required parameters:

   'phptype'      The database type (ie. 'pgsql', 'mysql', etc.).

Required by some database implementations:

   'database'     The name of the database.
   'hostspec'     The hostname of the database server.
   'username'     The username with which to connect to the database.
   'password'     The password associated with 'username'.
   'options'      Additional options to pass to the database.
   'tty'          The TTY on which to connect to the database.
   'port'         The port on which to connect to the database.

Optional parameters:

   'table'               The name of the cache table in 'database'.
                         Defaults to 'horde_cache'.
   'use_memorycache'     Use a Horde_Cache:: memory caching driver to cache
                         the data (to avoid DB accesses).  Either empty or
                         'none' if not needed, or else the name of a valid
                         Horde_Cache:: driver.

Optional values when using separate reading and writing servers, for example in replication settings:

   'splitread'   Boolean, whether to implement the separation or not.
   'read'        Array containing the parameters which are different for
                 the read database connection, currently supported
                 only 'hostspec' and 'port' parameters.

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)
 );

$Horde: framework/Cache/Cache/sql.php,v 1.12.2.13 2009/02/25 05:35:42 chuck Exp $

Copyright 2007-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /Cache/Cache/sql.php (line 60)

Horde_Cache
   |
   --Horde_Cache_sql
Variable Summary
 boolean $_connected
 DB $_db
 Horde_Cache $_mc
Method Summary
 Horde_Cache_sql Horde_Cache_sql ([array $params = array()])
 boolean exists (string $key, [integer $lifetime = 1])
 boolean expire (string $key)
 mixed get (string $key, [integer $lifetime = 1])
 boolean set (string $key, mixed $data, [integer $lifetime = null])
 boolean _connect ()
Variables
boolean $_connected = false (line 82)

Boolean indicating whether or not we're connected to the SQL server.

DB $_db (line 67)

Handle for the current database connection.

Horde_Cache $_mc = null (line 89)

The memory cache object to use, if configured.

DB $_write_db (line 75)

Handle for the current database connection, used for writing. Defaults to the same handle as $_db if a separate write database isn't required.

Inherited Variables

Inherited from Horde_Cache

Horde_Cache::$_params
Methods
Constructor Horde_Cache_sql (line 96)

Constructs a new Horde_Cache_sql object.

Horde_Cache_sql Horde_Cache_sql ([array $params = array()])
  • array $params: A hash containing configuration parameters.
exists (line 243)

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

  • return: Existance.
boolean exists (string $key, [integer $lifetime = 1])
  • string $key: Cache key to check.
  • integer $lifetime: Maximum age of the key in seconds or 0 for any object.

Redefinition of:
Horde_Cache::exists()
Checks if a given key exists in the cache, valid for the given lifetime.
expire (line 290)

Expire any existing data for the given key.

  • return: Success or failure.
boolean expire (string $key)
  • string $key: Cache key to expire.

Redefinition of:
Horde_Cache::expire()
Expire any existing data for the given key.
get (line 133)

Attempts to retrieve cached data.

  • return: Cached data, or false if none was found.
mixed get (string $key, [integer $lifetime = 1])
  • string $key: Cache key to fetch.
  • integer $lifetime: Maximum age of the data in seconds or
    1. for any object

Redefinition of:
Horde_Cache::get()
Attempts to retrieve a cached object and return it to the caller.
set (line 190)

Attempts to store data.

  • return: True on success, false on failure.
boolean set (string $key, mixed $data, [integer $lifetime = null])
  • string $key: Cache key.
  • mixed $data: Data to store in the cache. (MUST BE A STRING)
  • integer $lifetime: Maximum data life span or 0 for a non-expiring object. @since Horde 3.2

Redefinition of:
Horde_Cache::set()
Attempts to store an object in the cache.
_connect (line 319)

Opens a connection to the SQL server.

  • return: True on success, a PEAR_Error object on failure.
boolean _connect ()

Inherited Methods

Inherited From Horde_Cache

 Horde_Cache::Horde_Cache()
 Horde_Cache::exists()
 Horde_Cache::expire()
 Horde_Cache::factory()
 Horde_Cache::get()
 Horde_Cache::output()
 Horde_Cache::set()
 Horde_Cache::singleton()
 Horde_Cache::_getLifetime()

Documentation generated on Sun, 30 Jan 2011 05:21:49 +0000 by phpDocumentor 1.4.3