Skip to content

CI_Cache

Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

CI_Cache

CodeIgniter Caching Class

This class enables you to create "Driver" libraries that add runtime ability to extend the capabilities of a class via additional driver objects

Properties

$valid_drivers

protected array $valid_drivers = array()

Array of drivers that are available to use with the driver class

  • Visibility: protected

$_cache_path

protected string $_cache_path = NULL

Path of cache files (if file-based cache)

  • Visibility: protected

$_adapter

protected mixed $_adapter = 'dummy'

Reference to the driver

  • Visibility: protected

$_backup_driver

protected string $_backup_driver = 'dummy'

Fallback driver

  • Visibility: protected

$key_prefix

public string $key_prefix = ''

Cache key prefix

  • Visibility: public

$lib_name

protected string $lib_name

Name of the current class - usually the driver class

  • Visibility: protected

Methods

__construct

void CI_Cache::__construct(array $config)

Constructor

Initialize class properties based on the configuration array.

  • Visibility: public

Arguments

  • $config array - <p>= array()</p>

get

mixed CI_Cache::get(string $id)

Get

Look for a value in the cache. If it exists, return the data if not, return FALSE

  • Visibility: public

Arguments

  • $id string

save

boolean CI_Cache::save(string $id, mixed $data, integer $ttl, boolean $raw)

Cache Save

  • Visibility: public

Arguments

  • $id string - <p>Cache ID</p>
  • $data mixed - <p>Data to store</p>
  • $ttl integer - <p>Cache TTL (in seconds)</p>
  • $raw boolean - <p>Whether to store the raw value</p>

delete

boolean CI_Cache::delete(string $id)

Delete from Cache

  • Visibility: public

Arguments

  • $id string - <p>Cache ID</p>

increment

mixed CI_Cache::increment(string $id, integer $offset)

Increment a raw value

  • Visibility: public

Arguments

  • $id string - <p>Cache ID</p>
  • $offset integer - <p>Step/value to add</p>

decrement

mixed CI_Cache::decrement(string $id, integer $offset)

Decrement a raw value

  • Visibility: public

Arguments

  • $id string - <p>Cache ID</p>
  • $offset integer - <p>Step/value to reduce by</p>

clean

boolean CI_Cache::clean()

Clean the cache

  • Visibility: public

cache_info

mixed CI_Cache::cache_info(string $type)

Cache Info

  • Visibility: public

Arguments

  • $type string - <p>= 'user' user/filehits</p>

get_metadata

mixed CI_Cache::get_metadata(string $id)

Get Cache Metadata

  • Visibility: public

Arguments

  • $id string - <p>key to get cache metadata on</p>

is_supported

array CI_Cache::is_supported(string $driver)

Is the requested driver supported in this environment?

  • Visibility: public

Arguments

  • $driver string - <p>The driver to test</p>

__get

object CI_Driver_Library::__get($child)

Get magic method

The first time a child is used it won't exist, so we instantiate it subsequents calls will go straight to the proper child.

Arguments

  • $child mixed

load_driver

object CI_Driver_Library::load_driver($child)

Load driver

Separate load_driver call to support explicit driver load by library or user

Arguments

  • $child mixed
Clone this wiki locally