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() |
|---|
stringKey in the cache
stringto cache
integerTime in seconds. Default = 604800 = one week
booleanTrue 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() |
|---|
booleanhits() : 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() |
|---|
integermisses() : 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() |
|---|
integerscavenge() : integer
integerThe number of records deletedset(string $key, string $var, integer $expire) : boolean
| see | \DStructCacheInterface::set() |
|---|
stringKey in the cache
string
integerTime in seconds. Default = 604800 = one week
booleanTRUE 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() |
|---|
integerdoStatement(string $statement, array $values) : object
Caches prepared statements via prepareStatement().
| inherited_from | \Base::doStatement() |
|---|
stringSQL statement
arrayValues for SQL statement
objectExecuted PDO::StatementprepareStatement(string $statement) : object
If previously prepared, returns the cached statement
handle.
This method is usually called by doStatement().
| inherited_from | \Base::prepareStatement() |
|---|
stringSQL statement to prepare
objectPDO::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