HEX
Server: Apache
System: Linux andromeda.lojoweb.com 4.18.0-372.26.1.el8_6.x86_64 #1 SMP Tue Sep 13 06:07:14 EDT 2022 x86_64
User: nakedfoamlojoweb (1056)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/cwd/wp-content/plugins/woocommerce/vendor/automattic/jetpack-status/src/class-cache.php
<?php
/**
 * A static in-process cache for blog data.
 *
 * @package automattic/jetpack-status
 */

namespace Automattic\Jetpack\Status;

/**
 * A static in-process cache for blog data.
 *
 * For internal use only. Do not use this externally.
 */
class Cache {
	/**
	 * Cached data;
	 *
	 * @var array[]
	 */
	private static $cache = array();

	/**
	 * Get a value from the cache.
	 *
	 * @param string $key Key to fetch.
	 * @param mixed  $default Default value to return if the key is not set.
	 * @return mixed Data.
	 */
	public static function get( $key, $default = null ) {
		$blog_id = get_current_blog_id();
		return isset( self::$cache[ $blog_id ] ) && array_key_exists( $key, self::$cache[ $blog_id ] ) ? self::$cache[ $blog_id ][ $key ] : $default;
	}

	/**
	 * Set a value in the cache.
	 *
	 * @param string $key Key to set.
	 * @param mixed  $value Value to store.
	 */
	public static function set( $key, $value ) {
		$blog_id                         = get_current_blog_id();
		self::$cache[ $blog_id ][ $key ] = $value;
	}

	/**
	 * Clear the cache.
	 *
	 * This is intended for use in unit tests.
	 */
	public static function clear() {
		self::$cache = array();
	}
}