<?php

namespace WPSN\Core;

defined('ABSPATH') || exit;

final class Cache
{
    /**
     * @return mixed|null
     */
    public function get(string $key)
    {
        $value = wp_cache_get($key, 'wpsn');
        if ($value === false) {
            return null;
        }
        return $value;
    }

    /**
     * @param mixed $value
     */
    public function set(string $key, $value, int $ttl = 300): void
    {
        wp_cache_set($key, $value, 'wpsn', $ttl);
    }

    public function delete(string $key): void
    {
        wp_cache_delete($key, 'wpsn');
    }
}
