Facade for caching in the database.
Requires Prefs::DB_CACHE to be set to a database connection. The class will automatically switch to this database and then back everytime it uses the database. Database caching can be useful if you want to share information across multiple instances (like multiple servers) which are part of the same system. It can also allow more persistance. However, it is usually better (faster!) to use an in-memory cache such as APC if there is a single instance or MemCache for multiple instances.
package | dstruct_common |
---|---|
todo | Easy way to set up the database? |
add(string $key, string $var, integer $expire) : boolean
Will add an entry if $key does not already exist.
see | \DStructCacheInterface::add() |
---|
string
Key in the cache
string
to cache
integer
Time in seconds. Default = 604800 = one week
boolean
True for successclear()
SEE WARNING BELOW.
WARNING: This will currently clear the entire cache, not just the entries for this application! Use with extreme caution.
todo | restrict to cache entries which are part of this application! |
---|
delete(string $key) : boolean
get(string $key) : string
getInstance() : \DatabaseCache
Objects are singletons and so use this method to get an instance. If you impliment this interface, it is recommended that you declare the __constructor() as protected
hasServer() : boolean
Is the cache server this object uses available to be used by the system
see | \DStructCacheInterface::hasServer() |
---|
boolean
hits() : integer
Not persistent. Counts the number of times this cache object has been queried and returned existing data. Please check the documentation for each classes implimentation of this method, as the functionallity may vary across classes.
see | \DStructCacheInterface::hits() |
---|
integer
misses() : integer
Not persistent. Counts the number of times this cache object has been queried but had no data for that key. Please check the documentation for each classes implimentation of this method, as the functionallity may vary across classes.
see | \DStructCacheInterface::misses() |
---|
integer
scavenge() : integer
integer
The number of records deletedset(string $key, string $var, integer $expire) : boolean
see | \DStructCacheInterface::set() |
---|
string
Key in the cache
string
integer
Time in seconds. Default = 604800 = one week
boolean
TRUE if value was actually added, FALSE if otherwisewrites() : integer
Not persistent. Counts the number of times this cache object has been written to. Please check the documentation for each classes implimentation of this method, as the functionallity may vary across classes.
see | \DStructCacheInterface::writes() |
---|
integer
doStatement(string $statement, array $values) : object
Caches prepared statements via prepareStatement().
inherited_from | \Base::doStatement() |
---|
string
SQL statement
array
Values for SQL statement
object
Executed PDO::StatementprepareStatement(string $statement) : object
If previously prepared, returns the cached statement
handle.
This method is usually called by doStatement().
inherited_from | \Base::prepareStatement() |
---|
string
SQL statement to prepare
object
PDO::Statement$statements : array
inherited_from | \Base::$$statements |
---|
$failedwrites : integer
$hasserver : boolean
$hits : integer
$instance : object
$misses : integer
$sql_add : string
$sql_clear : string
$sql_delete : string
$sql_get : string
$sql_scavenge : string
$sql_set : string
$writes : integer