[ Index ]

PHP Cross Reference of Wordpress 2.9.1

title

Body

[close]

/wp-includes/ -> cache.php (summary)

Object Cache API

File Size: 452 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Object_Cache:: (10 methods):
  add()
  delete()
  flush()
  get()
  replace()
  set()
  stats()
  WP_Object_Cache()
  __construct()
  __destruct()

Defines 10 functions

  wp_cache_add()
  wp_cache_close()
  wp_cache_delete()
  wp_cache_flush()
  wp_cache_get()
  wp_cache_init()
  wp_cache_replace()
  wp_cache_set()
  wp_cache_add_global_groups()
  wp_cache_add_non_persistent_groups()

Class: WP_Object_Cache  - X-Ref

WordPress Object Cache

The WordPress Object Cache is used to save on trips to the database. The
Object Cache stores all of the cache data to memory and makes the cache
contents available by using a key, which is used to name and later retrieve
the cache contents.

The Object Cache can be replaced by other caching mechanisms by placing files
in the wp-content folder which is looked at in wp-settings. If that file
exists, then this file will not be included.

add($id, $data, $group = 'default', $expire = '')   X-Ref
Adds data to the cache if it doesn't already exist.

param: int|string $id What to call the contents in the cache
param: mixed $data The contents to store in the cache
param: string $group Where to group the cache contents
param: int $expire When to expire the cache contents
return: bool False if cache ID and group already exists, true on success

delete($id, $group = 'default', $force = false)   X-Ref
Remove the contents of the cache ID in the group

If the cache ID does not exist in the group and $force parameter is set
to false, then nothing will happen. The $force parameter is set to false
by default.

On success the group and the id will be added to the
$non_existant_objects property in the class.

param: int|string $id What the contents in the cache are called
param: string $group Where the cache contents are grouped
param: bool $force Optional. Whether to force the unsetting of the cache
return: bool False if the contents weren't deleted and true on success

flush()   X-Ref
Clears the object cache of all data

return: bool Always returns true

get($id, $group = 'default')   X-Ref
Retrieves the cache contents, if it exists

The contents will be first attempted to be retrieved by searching by the
ID in the cache group. If the cache is hit (success) then the contents
are returned.

On failure, the $non_existant_objects property is checked and if the
cache group and ID exist in there the cache misses will not be
incremented. If not in the nonexistant objects property, then the cache
misses will be incremented and the cache group and ID will be added to
the nonexistant objects.

param: int|string $id What the contents in the cache are called
param: string $group Where the cache contents are grouped
return: bool|mixed False on failure to retrieve contents or the cache

replace($id, $data, $group = 'default', $expire = '')   X-Ref
Replace the contents in the cache, if contents already exist

param: int|string $id What to call the contents in the cache
param: mixed $data The contents to store in the cache
param: string $group Where to group the cache contents
param: int $expire When to expire the cache contents
return: bool False if not exists, true if contents were replaced

set($id, $data, $group = 'default', $expire = '')   X-Ref
Sets the data contents into the cache

The cache contents is grouped by the $group parameter followed by the
$id. This allows for duplicate ids in unique groups. Therefore, naming of
the group should be used with care and should follow normal function
naming guidelines outside of core WordPress usage.

The $expire parameter is not used, because the cache will automatically
expire for each time a page is accessed and PHP finishes. The method is
more for cache plugins which use files.

param: int|string $id What to call the contents in the cache
param: mixed $data The contents to store in the cache
param: string $group Where to group the cache contents
param: int $expire Not Used
return: bool Always returns true

stats()   X-Ref
Echos the stats of the caching.

Gives the cache hits, and cache misses. Also prints every cached group,
key and the data.


WP_Object_Cache()   X-Ref
PHP4 constructor; Calls PHP 5 style constructor

return: WP_Object_Cache

__construct()   X-Ref
Sets up object properties; PHP 5 style constructor

return: null|WP_Object_Cache If cache is disabled, returns null.

__destruct()   X-Ref
Will save the object cache before object is completely destroyed.

Called upon object destruction, which should be when PHP ends.

return: bool True value. Won't be used by PHP

Functions
Functions that are not part of a class:

wp_cache_add($key, $data, $flag = '', $expire = 0)   X-Ref
Adds data to the cache, if the cache key doesn't aleady exist.

param: int|string $key The cache ID to use for retrieval later
param: mixed $data The data to add to the cache store
param: string $flag The group to add the cache to
param: int $expire When the cache data should be expired
return: unknown

wp_cache_close()   X-Ref
Closes the cache.

This function has ceased to do anything since WordPress 2.5. The
functionality was removed along with the rest of the persistant cache. This
does not mean that plugins can't implement this function when they need to
make sure that the cache is cleaned up after WordPress no longer needs it.

return: bool Always returns True

wp_cache_delete($id, $flag = '')   X-Ref
Removes the cache contents matching ID and flag.

param: int|string $id What the contents in the cache are called
param: string $flag Where the cache contents are grouped
return: bool True on successful removal, false on failure

wp_cache_flush()   X-Ref
Removes all cache items.

return: bool Always returns true

wp_cache_get($id, $flag = '')   X-Ref
Retrieves the cache contents from the cache by ID and flag.

param: int|string $id What the contents in the cache are called
param: string $flag Where the cache contents are grouped
return: bool|mixed False on failure to retrieve contents or the cache

wp_cache_init()   X-Ref
Sets up Object Cache Global and assigns it.


wp_cache_replace($key, $data, $flag = '', $expire = 0)   X-Ref
Replaces the contents of the cache with new data.

param: int|string $id What to call the contents in the cache
param: mixed $data The contents to store in the cache
param: string $flag Where to group the cache contents
param: int $expire When to expire the cache contents
return: bool False if cache ID and group already exists, true on success

wp_cache_set($key, $data, $flag = '', $expire = 0)   X-Ref
Saves the data to the cache.

param: int|string $id What to call the contents in the cache
param: mixed $data The contents to store in the cache
param: string $flag Where to group the cache contents
param: int $expire When to expire the cache contents
return: bool False if cache ID and group already exists, true on success

wp_cache_add_global_groups( $groups )   X-Ref
Adds a group or set of groups to the list of global groups.

param: string|array $groups A group or an array of groups to add

wp_cache_add_non_persistent_groups( $groups )   X-Ref
Adds a group or set of groups to the list of non-persistent groups.

param: string|array $groups A group or an array of groups to add



Generated: Fri Jan 8 00:19:48 2010 Cross-referenced by PHPXref 0.7