<?php

namespace Helpers\Cache;

// use Helpers\Session\ParseBase1;

trait WinCache
{
    
    public function __construct()
    {
    }
        
    /**
     * surchargeGetUcache
     *
     * @param  string $key
     * @return mixed
     */
    public static function surchargeGetUcache(string $key)
    {
        if (\Helpers\Cache\Cache::variableTest() == true) {
            return [];
        } else {
            return \wincache_ucache_get($key);
        }
    }
    
    /**
     * surchargeSetUcache
     *
     * @param  string $key
     * @param  mixed $value
     * @param  mixed $ttl
     * @return bool
     */
    public static function surchargeSetUcache(string $key, $value, $ttl = 0) : bool
    {
        if (\Helpers\Cache\Cache::variableTest() == true) {
            return true;
        } else {
            return \wincache_ucache_set($key, $value, $ttl);
        }
    }
    
    /**
     * surchargeUcacheExists
     *
     * @param  string $key
     * @return bool
     */
    public static function surchargeUcacheExists(string $key)
    {
        if (\Helpers\Cache\Cache::variableTest() == true) {
            return false;
        } else {
            return \wincache_ucache_exists($key);
        }
    }
    
    /**
     * surchargeDeleteUcache
     *
     * @param  string $key
     * @return bool
     */
    public static function surchargeDeleteUcache(string $key) : bool
    {
        if (\Helpers\Cache\Cache::variableTest() == true) {
            return false;
        } else {
            return \wincache_ucache_delete($key);
        }
    }
}
