<?php

namespace Components\Support;

/**
 * Class CacheService
 *
 * Reusable cache service for MailBeez.
 * Uses the database table TABLE_MAILBEEZ_MODULE_CONFIGURATION for persistence.
 *
 * @package Components\Support
 */
class CacheService extends ConfigStorageService
{
    /**
     * Store a value in the cache.
     *
     * @param string $key
     * @param mixed $value
     */
    public static function set(string $key, $value): void
    {
        parent::set($key, $value);
    }

    /**
     * Read a value from the cache.
     *
     * @param string $key
     * @return mixed|false Returns the cached value or false if not found.
     */
    public static function get(string $key)
    {
        return parent::get($key);
    }

    /**
     * Purge a value from the cache.
     *
     * @param string $key
     */
    public static function purge(string $key): void
    {
        parent::delete($key);
    }

    /**
     * Purge values matching a pattern from the cache.
     *
     * @param string $pattern
     */
    public static function purgePattern(string $pattern): void
    {
        parent::deletePattern($pattern);
    }
}
