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

Class: Cache_Container_db

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

Class Overview

Cache_Container
   |
   --Cache_Container_db

PEAR/DB Cache Container.


Author(s):

Version:

  • $Id: db.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 58]
PEAR/DB Cache Container.

WARNING: Other systems might or might not support certain datatypes of the tables shown. As far as I know there's no large binary type in SQL-92 or SQL-99. Postgres seems to lack any BLOB or TEXT type, for MS-SQL you could use IMAGE, don't know about other databases. Please add sugestions for other databases to the inline docs.

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.

For _MySQL_ you need this DB table:

CREATE TABLE cache ( id CHAR(32) NOT null DEFAULT '', cachegroup VARCHAR(127) NOT null DEFAULT '', cachedata BLOB NOT null DEFAULT '', userdata VARCHAR(255) NOT null DEFAULT '', expires INT(9) NOT null DEFAULT 0,

changed TIMESTAMP(14) NOT null,

INDEX (expires), PRIMARY KEY (id, cachegroup) )



[ Top ]


Class Variables

$cache_table =  ''

[line 66]

Name of the DB table to store caching data

Type:   mixed


[ Top ]

$db =

[line 80]

PEAR DB object

Type:   object PEAR_DB


[ Top ]

$dsn =  ''

[line 73]

PEAR DB dsn to use.

Type:   string


[ Top ]



Method Detail

Cache_Container_db (Constructor)   [line 82]

Cache_Container_db Cache_Container_db( $options)


Parameters:

   $options     

[ Top ]

fetch   [line 98]

void fetch( $id, $group)


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

Parameters:

   $id     
   $group     

[ Top ]

flush   [line 177]

void flush( [ $group = ''])


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

Parameters:

   $group     

[ Top ]

garbageCollection   [line 214]

void garbageCollection( $maxlifetime)


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

Parameters:

   $maxlifetime     

[ Top ]

idExists   [line 193]

void idExists( $id, $group)


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

Parameters:

   $id     
   $group     

[ Top ]

remove   [line 160]

void remove( $id, $group)


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

Parameters:

   $id     
   $group     

[ Top ]

save   [line 140]

void save( $id, $data, $expires, $group, $userdata)

Stores a dataset.

WARNING: we use the SQL command REPLACE INTO this might be MySQL specific. As MySQL is very popular the method should work fine for 95% of you.


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

Parameters:

   $id     
   $data     
   $expires     
   $group     
   $userdata     

[ Top ]


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