Cache Class Info:
- Class Declaration:
class Cache
- File name:
- cake/libs/cache.php
- Description:
Caching for CakePHP.
- Package
- cake
- Subpackage
- cake.cake.libs
Properties:
-
_engines array
Engine instances keyed by configuration name.
Method Summary:
- _buildEngine( $name )
- clear( $check = false, $config = NULL )
- config( $name = NULL, $settings = array ( ) )
- configured( )
- decrement( $key, $offset = 1, $config = NULL )
- delete( $key, $config = NULL )
- drop( $name )
- gc( )
- getInstance( )
- increment( $key, $offset = 1, $config = NULL )
- isInitialized( $name = NULL )
- read( $key, $config = NULL )
- set( $settings = array ( ), $value = NULL )
- settings( $name = NULL )
- write( $key, $value, $config = NULL )
_buildEngine
topFinds and builds the instance of the required engine class.
- Parameters:
-
-
string $name required
Name of the config array that needs an engine instance built
-
- Method defined in:
- cake/libs/cache.php on line 141
- Return
void
- Access
protected
clear
topDelete all keys from the cache.
- Parameters:
-
-
boolean $check optional false
if true will check expiration, otherwise delete all
-
string $config optional NULL
name of the configuration to use
-
- Method defined in:
- cake/libs/cache.php on line 476
- Return
boolean True if the cache was succesfully cleared, false otherwise
- Access
public
- Static
config
topSet the cache configuration to use. config() can both create new configurations, return the settings for already configured configurations. It also sets the 'default' configuration to use for subsequent operations.
To create a new configuration:
Cache::config('my_config', array('engine' => 'File', 'path' => TMP));
To get the settings for a configuration, and set it as the currently selected configuration
Cache::config('default');
- Parameters:
-
-
string $name optional NULL
Name of the configuration
-
array $settings optional array ( )
Optional associative array of settings passed to the engine
-
- Method defined in:
- cake/libs/cache.php on line 99
- See
app/config/core.php for configuration settings
- Return
array(engine, settings) on success, false on failure
- Access
public
- Static
configured
topReturns an array containing the currently configured Cache settings.
- Method defined in:
- cake/libs/cache.php on line 165
- Return
array Array of configured Cache config names.
decrement
topDecrement a number under the key and return decremented value.
- Parameters:
-
-
string $key required
Identifier for the data
-
integer $offset optional 1
How much to substract
-
string $config optional NULL
Optional string configuration name, if not specified the current default config will be used.
-
- Method defined in:
- cake/libs/cache.php on line 400
- Return
mixed new value, or false if the data doesn't exist, is not integer, or if there was an error fetching it
- Access
public
delete
topDelete a key from the cache. Will automatically use the currently active cache configuration. To set the currently active configuration use Cache::config()
Usage:
Deleting from the active cache configuration.
Cache::delete('my_data');
Deleting from a specific cache configuration.
Cache::delete('my_data', 'long_term');
- Parameters:
-
-
string $key required
Identifier for the data
-
string $config optional NULL
name of the configuration to use
-
- Method defined in:
- cake/libs/cache.php on line 444
- Return
boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed
- Access
public
- Static
drop
topDrops a cache engine. Deletes the cache configuration information If the deleted configuration is the last configuration using an certain engine, the Engine instance is also unset.
- Parameters:
-
-
string $name required
A currently configured cache config you wish to remove.
-
- Method defined in:
- cake/libs/cache.php on line 178
- Return
boolen success of the removal, returns false when the config does not exist.
gc
topGarbage collection
Permanently remove all expired and deleted data
- Method defined in:
- cake/libs/cache.php on line 256
- Return
void
- Access
public
- Static
getInstance
topReturns a singleton instance
- Method defined in:
- cake/libs/cache.php on line 70
- Return
object
- Access
public
- Static
increment
topIncrement a number under the key and return incremented value.
- Parameters:
-
-
string $key required
Identifier for the data
-
integer $offset optional 1
How much to add
-
string $config optional NULL
Optional string configuration name. If not specified the current default config will be used.
-
- Method defined in:
- cake/libs/cache.php on line 366
- Return
mixed new value, or false if the data doesn't exist, is not integer, or if there was an error fetching it.
- Access
public
isInitialized
topCheck if Cache has initialized a working config for the given name.
- Parameters:
-
-
$name optional NULL
-
- Method defined in:
- cake/libs/cache.php on line 504
- Return
bool Whether or not the config name has been initialized.
- Access
public
- Static
read
topRead a key from the cache. Will automatically use the currently active cache configuration. To set the currently active configuration use Cache::config()
Usage:
Reading from the active cache configuration.
Cache::read('my_data');
Reading from a specific cache configuration.
Cache::read('my_data', 'long_term');
- Parameters:
-
-
string $key required
Identifier for the data
-
string $config optional NULL
optional name of the configuration to use.
-
- Method defined in:
- cake/libs/cache.php on line 329
- Return
mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
- Access
public
- Static
set
topTemporarily change settings to current config options. if no params are passed, resets settings if needed Cache::write() will reset the configuration changes made
- Parameters:
-
-
mixed $settings optional array ( )
Optional string for simple name-value pair or array
-
string $value optional NULL
Optional for a simple name-value pair
-
- Method defined in:
- cake/libs/cache.php on line 219
- Return
array Array of settings.
- Access
public
- Static
settings
topReturn the settings for current cache engine. If no name is supplied the settings
for the 'active default' configuration will be returned. To set the 'active default'
configuration use Cache::config()
- Parameters:
-
-
$name optional NULL
-
- Method defined in:
- cake/libs/cache.php on line 526
- Return
array list of settings for this engine
- See
- Access
public
- Static
write
topWrite data for key into cache. Will automatically use the currently active cache configuration. To set the currently active configuration use Cache::config()
Usage:
Writing to the active cache config:
Cache::write('cached_data', $data);
Writing to a specific cache config:
Cache::write('cached_data', $data, 'long_term');
- Parameters:
-
-
string $key required
Identifier for the data
-
mixed $value required
Data to be cached - anything except a resource
-
string $config optional NULL
Optional string configuration name to write to.
-
- Method defined in:
- cake/libs/cache.php on line 283
- Return
boolean True if the data was successfully cached, false on failure
- Access
public
- Static