/bp-forums/bbpress/bb-includes/backpress/functions.wp-object-cache.php

  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. * Closes the cache. 
  35. * 
  36. * This function has ceased to do anything since WordPress 2.5. The 
  37. * functionality was removed along with the rest of the persistent cache. This 
  38. * does not mean that plugins can't implement this function when they need to 
  39. * make sure that the cache is cleaned up after WordPress no longer needs it. 
  40. * 
  41. * @since 2.0.0 
  42. * 
  43. * @return bool Always returns True 
  44. */ 
  45. function wp_cache_close() { 
  46. return true; 
  47.  
  48. /** 
  49. * Removes the cache contents matching ID and flag. 
  50. * 
  51. * @since 2.0.0 
  52. * @uses $wp_object_cache Object Cache Class 
  53. * @see WP_Object_Cache::delete() 
  54. * 
  55. * @param int|string $id What the contents in the cache are called 
  56. * @param string $flag Where the cache contents are grouped 
  57. * @return bool True on successful removal, false on failure 
  58. */ 
  59. function wp_cache_delete($id, $flag = '') { 
  60. global $wp_object_cache; 
  61.  
  62. return $wp_object_cache->delete($id, $flag); 
  63.  
  64. /** 
  65. * Removes all cache items. 
  66. * 
  67. * @since 2.0.0 
  68. * @uses $wp_object_cache Object Cache Class 
  69. * @see WP_Object_Cache::flush() 
  70. * 
  71. * @return bool Always returns true 
  72. */ 
  73. function wp_cache_flush( $group = null ) { 
  74. // WP does not support group flushing 
  75. global $wp_object_cache; 
  76.  
  77. return $wp_object_cache->flush( $group ); 
  78.  
  79. /** 
  80. * Retrieves the cache contents from the cache by ID and flag. 
  81. * 
  82. * @since 2.0.0 
  83. * @uses $wp_object_cache Object Cache Class 
  84. * @see WP_Object_Cache::get() 
  85. * 
  86. * @param int|string $id What the contents in the cache are called 
  87. * @param string $flag Where the cache contents are grouped 
  88. * @return bool|mixed False on failure to retrieve contents or the cache 
  89. * contents on success 
  90. */ 
  91. function wp_cache_get($id, $flag = '') { 
  92. global $wp_object_cache; 
  93.  
  94. return $wp_object_cache->get($id, $flag); 
  95.  
  96. /** 
  97. * Sets up Object Cache Global and assigns it. 
  98. * 
  99. * @since 2.0.0 
  100. * @global WP_Object_Cache $wp_object_cache WordPress Object Cache 
  101. */ 
  102. function wp_cache_init() { 
  103. $GLOBALS['wp_object_cache'] = new WP_Object_Cache(); 
  104.  
  105. /** 
  106. * Replaces the contents of the cache with new data. 
  107. * 
  108. * @since 2.0.0 
  109. * @uses $wp_object_cache Object Cache Class 
  110. * @see WP_Object_Cache::replace() 
  111. * 
  112. * @param int|string $id What to call the contents in the cache 
  113. * @param mixed $data The contents to store in the cache 
  114. * @param string $flag Where to group the cache contents 
  115. * @param int $expire When to expire the cache contents 
  116. * @return bool False if cache ID and group already exists, true on success 
  117. */ 
  118. function wp_cache_replace($key, $data, $flag = '', $expire = 0) { 
  119. global $wp_object_cache; 
  120.  
  121. return $wp_object_cache->replace($key, $data, $flag, $expire); 
  122.  
  123. /** 
  124. * Saves the data to the cache. 
  125. * 
  126. * @since 2.0 
  127. * @uses $wp_object_cache Object Cache Class 
  128. * @see WP_Object_Cache::set() 
  129. * 
  130. * @param int|string $id What to call the contents in the cache 
  131. * @param mixed $data The contents to store in the cache 
  132. * @param string $flag Where to group the cache contents 
  133. * @param int $expire When to expire the cache contents 
  134. * @return bool False if cache ID and group already exists, true on success 
  135. */ 
  136. function wp_cache_set($key, $data, $flag = '', $expire = 0) { 
  137. global $wp_object_cache; 
  138.  
  139. return $wp_object_cache->set($key, $data, $flag, $expire); 
  140.  
  141. /** 
  142. * Adds a group or set of groups to the list of global groups. 
  143. * 
  144. * @since 2.6.0 
  145. * 
  146. * @param string|array $groups A group or an array of groups to add 
  147. */ 
  148. function wp_cache_add_global_groups( $groups ) { 
  149. global $wp_object_cache; 
  150.  
  151. return $wp_object_cache->add_global_groups( $groups ); 
  152.  
  153. /** 
  154. * Adds a group or set of groups to the list of non-persistent groups. 
  155. * 
  156. * @since 2.6.0 
  157. * 
  158. * @param string|array $groups A group or an array of groups to add 
  159. */ 
  160. function wp_cache_add_non_persistent_groups( $groups ) { 
  161. global $wp_object_cache; 
  162.  
  163. return $wp_object_cache->add_non_persistent_groups( $groups ); 
.