[ Index ]

PHP Cross Reference of BackPress

title

Body

[close]

/includes/ -> functions.wp-object-cache.php (source)

   1  <?php
   2  // Last sync [WP11537]
   3  
   4  /**
   5   * Object Cache API
   6   *
   7   * @link http://codex.wordpress.org/Function_Reference/WP_Cache
   8   *
   9   * @package WordPress
  10   * @subpackage Cache
  11   */
  12  
  13  
  14  
  15  /**
  16   * Adds data to the cache, if the cache key doesn't aleady exist.
  17   *
  18   * @since 2.0.0
  19   * @uses $wp_object_cache Object Cache Class
  20   * @see WP_Object_Cache::add()
  21   *
  22   * @param int|string $key The cache ID to use for retrieval later
  23   * @param mixed $data The data to add to the cache store
  24   * @param string $flag The group to add the cache to
  25   * @param int $expire When the cache data should be expired
  26   * @return unknown
  27   */
  28  function wp_cache_add($key, $data, $flag = '', $expire = 0) {
  29      global $wp_object_cache;
  30  
  31      return $wp_object_cache->add($key, $data, $flag, $expire);
  32  }
  33  
  34  /**
  35   * Closes the cache.
  36   *
  37   * This function has ceased to do anything since WordPress 2.5. The
  38   * functionality was removed along with the rest of the persistent cache. This
  39   * does not mean that plugins can't implement this function when they need to
  40   * make sure that the cache is cleaned up after WordPress no longer needs it.
  41   *
  42   * @since 2.0.0
  43   *
  44   * @return bool Always returns True
  45   */
  46  function wp_cache_close() {
  47      return true;
  48  }
  49  
  50  /**
  51   * Removes the cache contents matching ID and flag.
  52   *
  53   * @since 2.0.0
  54   * @uses $wp_object_cache Object Cache Class
  55   * @see WP_Object_Cache::delete()
  56   *
  57   * @param int|string $id What the contents in the cache are called
  58   * @param string $flag Where the cache contents are grouped
  59   * @return bool True on successful removal, false on failure
  60   */
  61  function wp_cache_delete($id, $flag = '') {
  62      global $wp_object_cache;
  63  
  64      return $wp_object_cache->delete($id, $flag);
  65  }
  66  
  67  /**
  68   * Removes all cache items.
  69   *
  70   * @since 2.0.0
  71   * @uses $wp_object_cache Object Cache Class
  72   * @see WP_Object_Cache::flush()
  73   *
  74   * @return bool Always returns true
  75   */
  76  function wp_cache_flush( $group = null ) {
  77      // WP does not support group flushing
  78      global $wp_object_cache;
  79  
  80      return $wp_object_cache->flush( $group );
  81  }
  82  
  83  /**
  84   * Retrieves the cache contents from the cache by ID and flag.
  85   *
  86   * @since 2.0.0
  87   * @uses $wp_object_cache Object Cache Class
  88   * @see WP_Object_Cache::get()
  89   *
  90   * @param int|string $id What the contents in the cache are called
  91   * @param string $flag Where the cache contents are grouped
  92   * @return bool|mixed False on failure to retrieve contents or the cache
  93   *        contents on success
  94   */
  95  function wp_cache_get($id, $flag = '') {
  96      global $wp_object_cache;
  97  
  98      return $wp_object_cache->get($id, $flag);
  99  }
 100  
 101  /**
 102   * Sets up Object Cache Global and assigns it.
 103   *
 104   * @since 2.0.0
 105   * @global WP_Object_Cache $wp_object_cache WordPress Object Cache
 106   */
 107  function wp_cache_init() {
 108      $GLOBALS['wp_object_cache'] = new WP_Object_Cache();
 109  }
 110  
 111  /**
 112   * Replaces the contents of the cache with new data.
 113   *
 114   * @since 2.0.0
 115   * @uses $wp_object_cache Object Cache Class
 116   * @see WP_Object_Cache::replace()
 117   *
 118   * @param int|string $id What to call the contents in the cache
 119   * @param mixed $data The contents to store in the cache
 120   * @param string $flag Where to group the cache contents
 121   * @param int $expire When to expire the cache contents
 122   * @return bool False if cache ID and group already exists, true on success
 123   */
 124  function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
 125      global $wp_object_cache;
 126  
 127      return $wp_object_cache->replace($key, $data, $flag, $expire);
 128  }
 129  
 130  /**
 131   * Saves the data to the cache.
 132   *
 133   * @since 2.0
 134   * @uses $wp_object_cache Object Cache Class
 135   * @see WP_Object_Cache::set()
 136   *
 137   * @param int|string $id What to call the contents in the cache
 138   * @param mixed $data The contents to store in the cache
 139   * @param string $flag Where to group the cache contents
 140   * @param int $expire When to expire the cache contents
 141   * @return bool False if cache ID and group already exists, true on success
 142   */
 143  function wp_cache_set($key, $data, $flag = '', $expire = 0) {
 144      global $wp_object_cache;
 145  
 146      return $wp_object_cache->set($key, $data, $flag, $expire);
 147  }
 148  
 149  /**
 150   * Adds a group or set of groups to the list of global groups.
 151   *
 152   * @since 2.6.0
 153   *
 154   * @param string|array $groups A group or an array of groups to add
 155   */
 156  function wp_cache_add_global_groups( $groups ) {
 157      global $wp_object_cache;
 158  
 159      return $wp_object_cache->add_global_groups( $groups );
 160  }
 161  
 162  /**
 163   * Adds a group or set of groups to the list of non-persistent groups.
 164   *
 165   * @since 2.6.0
 166   *
 167   * @param string|array $groups A group or an array of groups to add
 168   */
 169  function wp_cache_add_non_persistent_groups( $groups ) {
 170      global $wp_object_cache;
 171  
 172      return $wp_object_cache->add_non_persistent_groups( $groups );
 173  }


Generated: Sat Nov 23 01:00:54 2024 Cross-referenced by PHPXref 0.7.1