CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BakeTask
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeRoute
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbConfigTask
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • FileLog
  • FixtureTask
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JqueryEngineHelper
  • JsBaseEngineHelper
  • JsHelper
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • MootoolsEngineHelper
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginShortRoute
  • PluginTask
  • ProjectTask
  • PrototypeEngineHelper
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • Set
  • Shell
  • String
  • TemplateTask
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count

Class Cache

Caching for CakePHP.

Package: cake\cake\libs
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: cache.php

Properties summary

  • $__config public
    array

    Cache configuration stack Keeps the permanent/default settings for each cache engine. These settings are used to reset the engines after temporary modification.

  • $__name public
    array
    Holds name of the current configuration name being used.
  • $__reset public
    array
    Whether to reset the settings with the next call to Cache::set();
  • $_engines public
    array
    Engine instances keyed by configuration name.

Method Summary

  • __destruct() public
    Write the session when session data is persisted with cache.
  • __loadEngine() public
    Tries to find and include a file for a cache engine and returns object instance
  • _buildEngine() public
    Finds and builds the instance of the required engine class.
  • clear() public
    Delete all keys from the cache.
  • config() public

    Set 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.

  • configured() public
    Returns an array containing the currently configured Cache settings.
  • decrement() public
    Decrement a number under the key and return decremented value.
  • delete() public

    Delete a key from the cache. Will automatically use the currently active cache configuration. To set the currently active configuration use Cache::config()

  • drop() public

    Drops 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.

  • gc() public
    Garbage collection
  • getInstance() public
    Returns a singleton instance
  • increment() public
    Increment a number under the key and return incremented value.
  • isInitialized() public
    Check if Cache has initialized a working config for the given name.
  • read() public

    Read a key from the cache. Will automatically use the currently active cache configuration. To set the currently active configuration use Cache::config()

  • set() public

    Temporarily change settings to current config options. if no params are passed, resets settings if needed Cache::write() will reset the configuration changes made

  • settings() public

    Return 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()

  • write() public

    Write data for key into cache. Will automatically use the currently active cache configuration. To set the currently active configuration use Cache::config()

Method Detail

__destruct() public ¶

__destruct( )

Write the session when session data is persisted with cache.

__loadEngine() public ¶

__loadEngine( $name , $plugin = null )

Tries to find and include a file for a cache engine and returns object instance

Parameters
$name
of the engine (without 'Engine')
$plugin optional null
Returns
mixed
$engine object or null

_buildEngine() public ¶

_buildEngine( string $name )

Finds and builds the instance of the required engine class.

Parameters
string $name
Name of the config array that needs an engine instance built

clear() public ¶

clear( boolean $check = false , string $config = null )

Delete 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
Returns
boolean
True if the cache was succesfully cleared, false otherwise

config() public ¶

config( string $name = null , array $settings = array() )

Set 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');

The following keys are used in core cache engines:

  • duration Specify how long items in this cache configuration last.
  • prefix Prefix appended to all entries. Good for when you need to share a keyspace with either another cache config or annother application.
  • probability Probability of hitting a cache gc cleanup. Setting to 0 will disable cache::gc from ever being called automatically.
  • `servers' Used by memcache. Give the address of the memcached servers to use.
  • compress Used by memcache. Enables memcache's compressed format.
  • serialize Used by FileCache. Should cache objects be serialized first.
  • path Used by FileCache. Path to where cachefiles should be saved.
  • lock Used by FileCache. Should files be locked before writing to them?
  • user Used by Xcache. Username for XCache
  • password Used by Xcache. Password for XCache
Parameters
string $name optional null
Name of the configuration
array $settings optional array()
Optional associative array of settings passed to the engine
Returns
array(engine,
settings) on success, false on failure
See
app/config/core.php for configuration settings

configured() public ¶

configured( )

Returns an array containing the currently configured Cache settings.

Returns
array
Array of configured Cache config names.

decrement() public ¶

decrement( string $key , integer $offset = 1 , string $config = null )

Decrement a number under the key and return decremented value.

Parameters
string $key
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.

Returns
mixed

new value, or false if the data doesn't exist, is not integer, or if there was an error fetching it


delete() public ¶

delete( string $key , string $config = null )

Delete 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
Identifier for the data
string $config optional null
name of the configuration to use
Returns
boolean
True if the value was succesfully deleted, false if it didn't exist or couldn't be removed

drop() public ¶

drop( string $name )

Drops 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
A currently configured cache config you wish to remove.
Returns
boolen
success of the removal, returns false when the config does not exist.

gc() public ¶

gc( )

Garbage collection

Permanently remove all expired and deleted data

getInstance() public ¶

getInstance( )

Returns a singleton instance

Returns
object

increment() public ¶

increment( string $key , integer $offset = 1 , string $config = null )

Increment a number under the key and return incremented value.

Parameters
string $key
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.

Returns
mixed

new value, or false if the data doesn't exist, is not integer, or if there was an error fetching it.


isInitialized() public ¶

isInitialized( string $name = null , string $config ,… )

Check if Cache has initialized a working config for the given name.

Parameters
string $name optional null
$engine Name of the engine
string $config ,…
Name of the configuration setting
Returns
boolean
Whether or not the config name has been initialized.

read() public ¶

read( string $key , string $config = null )

Read 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
Identifier for the data
string $config optional null
optional name of the configuration to use.
Returns
mixed
The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it

set() public ¶

set( mixed $settings = array() , string $value = null )

Temporarily 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
Returns
array
Array of settings.

settings() public ¶

settings( string $name = null )

Return 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
string $name optional null
$engine Name of the configuration to get settings for.
Returns
array
list of settings for this engine
See
Cache::config()

write() public ¶

write( string $key , mixed $value , string $config = null )

Write 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
Identifier for the data
mixed $value
Data to be cached - anything except a resource
string $config optional null
Optional string configuration name to write to.
Returns
boolean
True if the data was successfully cached, false on failure

Properties detail

$__config ¶

public array

Cache configuration stack Keeps the permanent/default settings for each cache engine. These settings are used to reset the engines after temporary modification.

array()

$__name ¶

public array

Holds name of the current configuration name being used.

'default'

$__reset ¶

public array

Whether to reset the settings with the next call to Cache::set();

false

$_engines ¶

public array

Engine instances keyed by configuration name.

array()
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs