_global_groups( $groups ) { if ( ! is_array( $groups ) ) { $groups = array( $groups ); } foreach ( $groups as $group ) { $cache = $this->_get_engine( $group ); $cache->add_global_groups( array( $group ) ); } } /** * Adds non-persistent cache groups to the cache engine. * * @param mixed $groups An array or string of cache groups to add as non-persistent. * * @return void */ public function add_nonpersistent_groups( $groups ) { if ( ! is_array( $groups ) ) { $groups = array( $groups ); } foreach ( $groups as $group ) { $cache = $this->_get_engine( $group ); $cache->add_nonpersistent_groups( array( $group ) ); } } /** * Retrieves the appropriate cache engine based on the group. * * @param string $group The cache group. * * @return object The cache engine for the specified group. */ private function _get_engine( $group = '' ) { if ( isset( $this->_cache_by_group[ $group ] ) ) { return $this->_cache_by_group[ $group ]; } return $this->_default_cache; } /** * Decreases the cached value of a given ID by a specified offset. * * @param string $id The cache key. * @param int $offset The value to decrease by. * @param string $group The cache group. * * @return mixed The updated value if successful, otherwise false. */ public function decr( $id, $offset = 1, $group = 'default' ) { $cache = $this->_get_engine( $group ); return $cache->decr( $id, $offset, $group ); } /** * Increases the cached value of a given ID by a specified offset. * * @param string $id The cache key. * @param int $offset The value to increase by. * @param string $group The cache group. * * @return mixed The updated value if successful, otherwise false. */ public function incr( $id, $offset = 1, $group = 'default' ) { $cache = $this->_get_engine( $group ); return $cache->incr( $id, $offset, $group ); } /** * Switches to a different blog context in a multisite environment. * * @param int $blog_id The blog ID to switch to. * * @return void */ public function switch_to_blog( $blog_id ) { foreach ( $this->_caches as $cache ) { $cache->switch_blog( $blog_id ); } } }