HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/Cache.php
<?php

namespace AutomateWoo;

/**
 * Cache class.
 *
 * Wrapper class for WP transients and object cache.
 *
 * @since 2.1.0
 */
class Cache {

	/**
	 * Is cache enabled?
	 *
	 * @var bool
	 */
	public static $enabled = true;

	/**
	 * Get default transient expiration value in hours.
	 *
	 * @return int
	 */
	public static function get_default_transient_expiration() {
		return apply_filters( 'automatewoo_cache_default_expiration', 6 );
	}

	/**
	 * Set a transient value.
	 *
	 * @param string   $key
	 * @param mixed    $value
	 * @param bool|int $expiration In hours. Optional.
	 *
	 * @return bool
	 */
	public static function set_transient( $key, $value, $expiration = false ) {
		if ( ! self::$enabled ) {
			return false;
		}
		if ( ! $expiration ) {
			$expiration = self::get_default_transient_expiration();
		}
		return set_transient( 'aw_cache_' . $key, $value, $expiration * HOUR_IN_SECONDS );
	}

	/**
	 * Get the value of a transient.
	 *
	 * @param string $key
	 *
	 * @return bool|mixed
	 */
	public static function get_transient( $key ) {
		if ( ! self::$enabled ) {
			return false;
		}
		return get_transient( 'aw_cache_' . $key );
	}

	/**
	 * Delete a transient.
	 *
	 * @param string $key
	 */
	public static function delete_transient( $key ) {
		delete_transient( 'aw_cache_' . $key );
	}

	/**
	 * Sets a value in cache.
	 *
	 * Only sets if key is not falsy.
	 *
	 * @param string $key
	 * @param mixed  $value
	 * @param string $group
	 */
	public static function set( $key, $value, $group ) {
		if ( ! $key || ! self::$enabled ) {
			return;
		}
		wp_cache_set( (string) $key, $value, "automatewoo_$group" );
	}

	/**
	 * Retrieves the cache contents from the cache by key and group.
	 *
	 * @param string $key
	 * @param string $group
	 *
	 * @return bool|mixed
	 */
	public static function get( $key, $group ) {
		if ( ! $key || ! self::$enabled ) {
			return false;
		}
		return wp_cache_get( (string) $key, "automatewoo_$group" );
	}

	/**
	 * Checks if a cache key and group value exists.
	 *
	 * @param string $key
	 * @param string $group
	 *
	 * @return bool
	 */
	public static function exists( $key, $group ) {
		if ( ! $key || ! self::$enabled ) {
			return false;
		}
		$found = false;
		wp_cache_get( (string) $key, "automatewoo_$group", false, $found );
		return $found;
	}

	/**
	 * Remove the item from the cache.
	 *
	 * @param string $key
	 * @param string $group
	 */
	public static function delete( $key, $group ) {
		if ( ! $key || ! self::$enabled ) {
			return;
		}
		wp_cache_delete( (string) $key, "automatewoo_$group" );
	}

}