<?php
/**
 * Cache interface for PDFDraft.
 *
 * @package PDFDraft
 */

namespace PDFDraft\Contracts\Cache;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Defines the contract for cache implementations.
 */
interface CacheInterface {
	/**
	 * Retrieve a value from cache.
	 *
	 * @param string $key     Cache key.
	 * @param mixed  $default Default value if key does not exist.
	 * @return mixed
	 */
	public function get( string $key, $default = null );

	/**
	 * Store a value in cache.
	 *
	 * @param string $key   Cache key.
	 * @param mixed  $value Value to cache.
	 * @param int    $ttl   Time to live in seconds.
	 * @return bool True on success, false on failure.
	 */
	public function set( string $key, $value, int $ttl = 3600 ): bool;

	/**
	 * Delete a value from cache.
	 *
	 * @param string $key Cache key.
	 * @return bool True on success, false on failure.
	 */
	public function delete( string $key ): bool;

	/**
	 * Check if a key exists in cache.
	 *
	 * @param string $key Cache key.
	 * @return bool
	 */
	public function has( string $key ): bool;

	/**
	 * Clear all cache entries.
	 *
	 * @return bool True on success, false on failure.
	 */
	public function clear(): bool;
}
