Cache
[ class tree: Cache ] [ index: Cache ] [ all elements ]

Class: Cache_Container_mdb

Source Location: /Cache-1.5.7/Cache/Container/mdb.php

Class Overview

Cache_Container
   |
   --Cache_Container_mdb

PEAR/MDB Cache Container.


Author(s):

Version:

  • $Id: mdb.php 315100 2011-08-17 19:32:23Z cweiske $

Variables

Methods


Inherited Variables

Inherited Methods

Class: Cache_Container

Cache_Container::decode()
Decodes the data from the storage container.
Cache_Container::encode()
Encodes the data for the storage container.
Cache_Container::fetch()
Fetches a dataset from the storage medium.
Cache_Container::flush()
Flushes the cache - removes all caches datasets from the cache.
Cache_Container::flushPreload()
Flushes the internal preload buffer.
Cache_Container::garbageCollection()
Starts the garbage collection.
Cache_Container::getAllowedOptions()
Getter to allowed Configurations Options
Cache_Container::getExpiresAbsolute()
Translates human readable/relative times in unixtime
Cache_Container::getUserdata()
Returns the userdata field of a cached data set.
Cache_Container::hasBeenSet()
Verify that a configuration option has been set
Cache_Container::idExists()
Checks if a dataset exists.
Cache_Container::isCached()
Checks if a dataset is cached.
Cache_Container::isExpired()
Checks if a dataset is expired.
Cache_Container::load()
Loads a dataset from the cache.
Cache_Container::preload()
Does a speculative preload of a dataset
Cache_Container::remove()
Removes a dataset.
Cache_Container::save()
Stores a dataset.
Cache_Container::setAllowedOptions()
Set the Allowed Parameters to Container Type
Cache_Container::setOptions()
Imports the requested datafields as object variables if allowed

Class Details

[line 67]
PEAR/MDB Cache Container.

NB: The field 'changed' has no meaning for the Cache itself. It's just there because it's a good idea to have an automatically updated timestamp field for debugging in all of your tables.

A XML MDB-compliant schema example for the table needed is provided. Look at the file "mdb_cache_schema.xml" for that.

------------------------------------------ A basic usage example: ------------------------------------------

$dbinfo = array( 'database' => 'dbname', 'phptype' => 'mysql', 'username' => 'root', 'password' => '', 'cache_table' => 'cache' );

$cache = new Cache('mdb', $dbinfo); $id = $cache->generateID('testentry');

if ($data = $cache->get($id)) { echo 'Cache hit.
Data: '.$data;

} else { $data = 'data of any kind'; $cache->save($id, $data); echo 'Cache miss.
'; }

------------------------------------------



[ Top ]


Class Variables

$cache_table =  ''

[line 75]

Name of the MDB table to store caching data

Type:   mixed


[ Top ]

$db =

[line 82]

PEAR MDB object

Type:   object PEAR_MDB


[ Top ]



Method Detail

Cache_Container_mdb (Constructor)   [line 89]

Cache_Container_mdb Cache_Container_mdb( mixed $options)

Constructor

Parameters:

mixed   $options     Array with connection info or dsn string

[ Top ]

fetch   [line 112]

mixed fetch( string $id, string $group)

Fetch in the db the data that matches input parameters
  • Return: dataset value or null/Cache_Error on failure
  • Access: public

Overrides Cache_Container::fetch() (Fetches a dataset from the storage medium.)

Parameters:

string   $id     dataset ID
string   $group     cache group

[ Top ]

flush   [line 285]

void flush( [string $group = ''])

Remove all cached data for a certain group, or empty the cache table if no group is specified.

Overrides Cache_Container::flush() (Flushes the cache - removes all caches datasets from the cache.)

Parameters:

string   $group     cache group

[ Top ]

garbageCollection   [line 334]

void garbageCollection( int $maxlifetime)

Garbage collector.

Overrides Cache_Container::garbageCollection() (Starts the garbage collection.)

Parameters:

int   $maxlifetime     maxlifetime

[ Top ]

idExists   [line 310]

boolean idExists( string $id, string $group)

Check if a dataset ID/group exists.

Overrides Cache_Container::idExists() (Checks if a dataset exists.)

Parameters:

string   $id     dataset ID
string   $group     cache group

[ Top ]

remove   [line 264]

void remove( string $id, string $group)

Removes a dataset from the database

Overrides Cache_Container::remove() (Removes a dataset.)

Parameters:

string   $id     dataset ID
string   $group     cache group

[ Top ]

save   [line 194]

void save( string $id, mixed $data, integer $expires, string $group, string $userdata)

Stores a dataset in the database

If dataset_ID already exists, overwrite it with new data, else insert data in a new record.

  • Access: public

Overrides Cache_Container::save() (Stores a dataset.)

Parameters:

string   $id     dataset ID
mixed   $data     data to be cached
integer   $expires     expiration time
string   $group     cache group
string   $userdata     userdata

[ Top ]


Documentation generated on Thu, 15 Sep 2011 07:00:05 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.