@@ 414-429 (lines=16) @@ | ||
411 | * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). |
|
412 | * @return bool False if cache key and group already exist, true on success |
|
413 | */ |
|
414 | public function add( $key, $data, $group = 'default', $expire = 0 ) { |
|
415 | if ( wp_suspend_cache_addition() ) |
|
416 | return false; |
|
417 | ||
418 | if ( empty( $group ) ) |
|
419 | $group = 'default'; |
|
420 | ||
421 | $id = $key; |
|
422 | if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
423 | $id = $this->blog_prefix . $key; |
|
424 | ||
425 | if ( $this->_exists( $id, $group ) ) |
|
426 | return false; |
|
427 | ||
428 | return $this->set( $key, $data, $group, (int) $expire ); |
|
429 | } |
|
430 | ||
431 | /** |
|
432 | * Sets the list of global cache groups. |
|
@@ 610-622 (lines=13) @@ | ||
607 | * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). |
|
608 | * @return bool False if not exists, true if contents were replaced. |
|
609 | */ |
|
610 | public function replace( $key, $data, $group = 'default', $expire = 0 ) { |
|
611 | if ( empty( $group ) ) |
|
612 | $group = 'default'; |
|
613 | ||
614 | $id = $key; |
|
615 | if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
616 | $id = $this->blog_prefix . $key; |
|
617 | ||
618 | if ( ! $this->_exists( $id, $group ) ) |
|
619 | return false; |
|
620 | ||
621 | return $this->set( $key, $data, $group, (int) $expire ); |
|
622 | } |
|
623 | ||
624 | /** |
|
625 | * Resets cache keys. |