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

Class: Cache_Container_phplib

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

Class Overview

Cache_Container
   |
   --Cache_Container_phplib

Stores cache data into a database table using PHPLibs DB abstraction.


Author(s):

Version:

  • $Id: phplib.php 316194 2011-09-05 20:35:25Z 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 57]
Stores cache data into a database table using PHPLibs DB abstraction.

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' is used by the garbage collection. Depending on your databasesystem you might have to subclass fetch() and garbageCollection().

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 DEFAUL '', expires INT(9) NOT null DEFAULT 0,

changed TIMESTAMP(14) NOT null,

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



[ Top ]


Class Variables

$cache_table =  'cache'

[line 64]

Name of the DB table to store caching data

Type:   mixed


[ Top ]

$db =

[line 71]

PHPLib object

Type:   object PEAR_DB


[ Top ]

$db_class =  ''

[line 79]

Name of the PHPLib DB class to use

Type:   string


[ Top ]

$local_file =  ''

[line 88]

Filename of your local.inc

If empty, 'local.inc' is assumed.


Type:   string


[ Top ]

$local_path =  ''

[line 102]

Include path for you local.inc

HINT: If your're not using PHPLib's prepend.php you must take care that all classes (files) references by you local.inc are included automatically. So you might want to write a new local2.inc that only referrs to the database class (file) you're using and includes all required files.


Type:   string


[ Top ]



Method Detail

Cache_Container_phplib (Constructor)   [line 119]

Cache_Container_phplib Cache_Container_phplib( [mixed $options = null])

Creates an instance of a phplib db class to use it for storage.

Parameters:

mixed   $options     If empty the object tries to used the preconfigured class variables. If given it must be an array with: db_class => name of the DB class to use optional: db_file => filename of the DB class db_path => path to the DB class local_file => kind of local.inc local_patk => path to the local.inc see $local_path for some hints.s

[ Top ]

fetch   [line 142]

void fetch( $id, $group)


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

Parameters:

   $id     
   $group     

[ Top ]

flush   [line 201]

void flush( $group)


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

Parameters:

   $group     

[ Top ]

garbageCollection   [line 227]

void garbageCollection( $maxlifetime)


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

Parameters:

   $maxlifetime     

[ Top ]

idExists   [line 214]

void idExists( $id, $group)


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

Parameters:

   $id     
   $group     

[ Top ]

remove   [line 187]

void remove( $id, $group)


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

Parameters:

   $id     
   $group     

[ Top ]

save   [line 171]

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

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     

[ Top ]


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