Changeset 34227
- Timestamp:
- 09/16/2015 10:02:20 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cache.php
r34226 r34227 273 273 274 274 /** 275 * WordPress Object Cache275 * Core class that implements an object cache. 276 276 * 277 277 * The WordPress Object Cache is used to save on trips to the database. The … … 291 291 292 292 /** 293 * Holds the cached objects 294 * 293 * Holds the cached objects. 294 * 295 * @since 2.0.0 296 * @access private 295 297 * @var array 296 * @access private297 * @since 2.0.0298 298 */ 299 299 private $cache = array(); … … 309 309 310 310 /** 311 * Amount of times the cache did not have the request in cache 312 * 311 * Amount of times the cache did not have the request in cache. 312 * 313 * @since 2.0.0 314 * @access public 313 315 * @var int 314 * @access public315 * @since 2.0.0316 316 */ 317 317 public $cache_misses = 0; 318 318 319 319 /** 320 * List of global groups 321 * 320 * List of global cache groups. 321 * 322 * @since 3.0.0 323 * @access protected 322 324 * @var array 323 * @access protected324 * @since 3.0.0325 325 */ 326 326 protected $global_groups = array(); … … 329 329 * The blog prefix to prepend to keys in non-global groups. 330 330 * 331 * @since 3.5.0 332 * @access private 331 333 * @var int 334 */ 335 private $blog_prefix; 336 337 /** 338 * Holds the value of is_multisite(). 339 * 340 * @since 3.5.0 332 341 * @access private 333 * @since 3.5.0334 */335 private $blog_prefix;336 337 /**338 * Holds the value of `is_multisite()`339 *340 342 * @var bool 341 * @access private342 * @since 3.5.0343 343 */ 344 344 private $multisite; 345 345 346 346 /** 347 * Make private properties readable for backwards compatibility.347 * Makes private properties readable for backwards compatibility. 348 348 * 349 349 * @since 4.0.0 … … 358 358 359 359 /** 360 * Make private properties settable for backwards compatibility.360 * Makes private properties settable for backwards compatibility. 361 361 * 362 362 * @since 4.0.0 … … 372 372 373 373 /** 374 * Make private properties checkable for backwards compatibility.374 * Makes private properties checkable for backwards compatibility. 375 375 * 376 376 * @since 4.0.0 … … 385 385 386 386 /** 387 * Make private properties un-settable for backwards compatibility.387 * Makes private properties un-settable for backwards compatibility. 388 388 * 389 389 * @since 4.0.0 … … 399 399 * Adds data to the cache if it doesn't already exist. 400 400 * 401 * @uses WP_Object_Cache::_exists Checks to see if the cache already has data. 402 * @uses WP_Object_Cache::set Sets the data after the checking the cache 403 * contents existence. 404 * 405 * @since 2.0.0 406 * 407 * @param int|string $key What to call the contents in the cache 408 * @param mixed $data The contents to store in the cache 409 * @param string $group Where to group the cache contents 410 * @param int $expire When to expire the cache contents 401 * @since 2.0.0 402 * @access public 403 * 404 * @uses WP_Object_Cache::_exists() Checks to see if the cache already has data. 405 * @uses WP_Object_Cache::set() Sets the data after the checking the cache 406 * contents existence. 407 * 408 * @param int|string $key What to call the contents in the cache. 409 * @param mixed $data The contents to store in the cache. 410 * @param string $group Optional. Where to group the cache contents. Default 'default'. 411 * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). 411 412 * @return bool False if cache key and group already exist, true on success 412 413 */ … … 429 430 430 431 /** 431 * Sets the list of global groups.432 * Sets the list of global cache groups. 432 433 * 433 434 * @since 3.0.0 435 * @access public 434 436 * 435 437 * @param array $groups List of groups that are global. … … 443 445 444 446 /** 445 * Decrement numeric cache item's value447 * Decrements numeric cache item's value. 446 448 * 447 449 * @since 3.3.0 448 * 449 * @param int|string $key The cache key to decrement. 450 * @param int $offset The amount by which to decrement the item's value. Default is 1. 451 * @param string $group The group the key is in. 450 * @access public 451 * 452 * @param int|string $key The cache key to decrement. 453 * @param int $offset Optional. The amount by which to decrement the item's value. Default 1. 454 * @param string $group Optional. The group the key is in. Default 'default'. 452 455 * @return false|int False on failure, the item's new value on success. 453 456 */ … … 476 479 477 480 /** 478 * Remove the contents of the cache key in the group481 * Removes the contents of the cache key in the group. 479 482 * 480 483 * If the cache key does not exist in the group, then nothing will happen. 481 484 * 482 485 * @since 2.0.0 483 * 484 * @param int|string $key What the contents in the cache are called485 * @param string $group Where the cache contents are grouped486 * @param bool $deprecated Deprecated.487 * 488 * @return bool False if the contents weren't deleted and true on success 486 * @access public 487 * 488 * @param int|string $key What the contents in the cache are called. 489 * @param string $group Optional. Where the cache contents are grouped. Default 'default'. 490 * @param bool $deprecated Optional. Unused. Default false. 491 * @return bool False if the contents weren't deleted and true on success. 489 492 */ 490 493 public function delete( $key, $group = 'default', $deprecated = false ) { … … 503 506 504 507 /** 505 * Clears the object cache of all data 506 * 507 * @since 2.0.0 508 * 509 * @return true Always returns true 508 * Clears the object cache of all data. 509 * 510 * @since 2.0.0 511 * @access public 512 * 513 * @return true Always returns true. 510 514 */ 511 515 public function flush() { … … 516 520 517 521 /** 518 * Retrieves the cache contents, if it exists 522 * Retrieves the cache contents, if it exists. 519 523 * 520 524 * The contents will be first attempted to be retrieved by searching by the … … 525 529 * 526 530 * @since 2.0.0 527 * 528 * @param int|string $key What the contents in the cache are called 529 * @param string $group Where the cache contents are grouped 530 * @param string $force Whether to force a refetch rather than relying on the local cache (default is false) 531 * @return false|mixed False on failure to retrieve contents or the cache 532 * contents on success 531 * @access public 532 * 533 * @param int|string $key What the contents in the cache are called. 534 * @param string $group Optional. Where the cache contents are grouped. Default 'default'. 535 * @param string $force Optional. Unused. Whether to force a refetch rather than relying on the local 536 * cache. Default false. 537 * @param bool &$found Optional. Whether the key was found in the cache. Disambiguates a return of 538 * false, a storable value. Passed by reference. Default null. 539 * @return false|mixed False on failure to retrieve contents or the cache contents on success. 533 540 */ 534 541 public function get( $key, $group = 'default', $force = false, &$found = null ) { … … 554 561 555 562 /** 556 * Increment numeric cache item's value563 * Increments numeric cache item's value. 557 564 * 558 565 * @since 3.3.0 559 * 560 * @param int|string $key The cache key to increment 561 * @param int $offset The amount by which to increment the item's value. Default is 1. 562 * @param string $group The group the key is in. 566 * @access public 567 * 568 * @param int|string $key The cache key to increment 569 * @param int $offset Optional. The amount by which to increment the item's value. Default 1. 570 * @param string $group Optional. The group the key is in. Default 'default'. 563 571 * @return false|int False on failure, the item's new value on success. 564 572 */ … … 587 595 588 596 /** 589 * Replace the contents in the cache, if contents already exist 590 * 591 * @since 2.0.0 597 * Replaces the contents in the cache, if contents already exist. 598 * 599 * @since 2.0.0 600 * @access public 601 * 592 602 * @see WP_Object_Cache::set() 593 603 * 594 * @param int|string $key What to call the contents in the cache595 * @param mixed $data The contents to store in the cache596 * @param string $group Where to group the cache contents597 * @param int $expire When to expire the cache contents598 * @return bool False if not exists, true if contents were replaced 604 * @param int|string $key What to call the contents in the cache. 605 * @param mixed $data The contents to store in the cache. 606 * @param string $group Optional. Where to group the cache contents. Default 'default'. 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. 599 609 */ 600 610 public function replace( $key, $data, $group = 'default', $expire = 0 ) { … … 613 623 614 624 /** 615 * Reset keys625 * Resets cache keys. 616 626 * 617 627 * @since 3.0.0 628 * @access public 629 * 618 630 * @deprecated 3.5.0 Use switch_to_blog() 619 631 * @see switch_to_blog() … … 630 642 631 643 /** 632 * Sets the data contents into the cache 644 * Sets the data contents into the cache. 633 645 * 634 646 * The cache contents is grouped by the $group parameter followed by the … … 642 654 * 643 655 * @since 2.0.0 644 * 645 * @param int|string $key What to call the contents in the cache 646 * @param mixed $data The contents to store in the cache 647 * @param string $group Where to group the cache contents 648 * @param int $expire Not Used 649 * @return true Always returns true 656 * @access public 657 * 658 * @param int|string $key What to call the contents in the cache. 659 * @param mixed $data The contents to store in the cache. 660 * @param string $group Optional. Where to group the cache contents. Default 'default'. 661 * @param int $expire Not Used. 662 * @return true Always returns true. 650 663 */ 651 664 public function set( $key, $data, $group = 'default', $expire = 0 ) { … … 670 683 * 671 684 * @since 2.0.0 685 * @access public 672 686 */ 673 687 public function stats() { … … 684 698 685 699 /** 686 * Switch the interal blog id.687 * 688 * This changes the blog idused to create keys in blog specific groups.700 * Switches the interal blog ID. 701 * 702 * This changes the blog ID used to create keys in blog specific groups. 689 703 * 690 704 * @since 3.5.0 691 * 692 * @param int $blog_id Blog ID 705 * @access public 706 * 707 * @param int $blog_id Blog ID. 693 708 */ 694 709 public function switch_to_blog( $blog_id ) { … … 698 713 699 714 /** 700 * Utility function to determine whether a key exists in the cache.715 * Serves as a utility function to determine whether a key exists in the cache. 701 716 * 702 717 * @since 3.4.0 703 *704 718 * @access protected 705 * @param string $key 706 * @param string $group 707 * @return bool 719 * 720 * @param int|string $key Cache key to check for existence. 721 * @param string $group Cache group for the key existence check. 722 * @return bool Whether the key exists in the cache for the given group. 708 723 */ 709 724 protected function _exists( $key, $group ) { … … 712 727 713 728 /** 714 * Sets up object properties; PHP 5 style constructor 729 * Sets up object properties; PHP 5 style constructor. 715 730 * 716 731 * @since 2.0.8 717 732 * 718 * @global int $blog_id 733 * @global int $blog_id Global blog ID. 719 734 */ 720 735 public function __construct() { … … 733 748 734 749 /** 735 * Will savethe object cache before object is completely destroyed.750 * Saves the object cache before object is completely destroyed. 736 751 * 737 752 * Called upon object destruction, which should be when PHP ends. 738 753 * 739 * @since 740 * 741 * @return true True value. Won't be used by PHP754 * @since 2.0.8 755 * 756 * @return true Always returns true. 742 757 */ 743 758 public function __destruct() {
Note: See TracChangeset
for help on using the changeset viewer.