<?php
namespace Biz\Cache;

use phpFastCache\Helper\Psr16Adapter;



class Cache
{
    private $_cache;
    public function __construct()
    {
        $this->_cache = $this->_load();
    }

    private function _load()
    {
        if (!file_exists(ROOT_PATH . '/Config/Cache.php')) {
            throw new \Exception("Cache Configuration no exists!");
        }
        $config = require_once ROOT_PATH . '/Config/Cache.php';
        $cacheType = $config['type'];
        unset($config['type']);
        return new Psr16Adapter($cacheType, $config);
    }
    private function checkCacheObj(){
        if(!$this->_cache){
            return 0;
        }
        return 1;
    }
    public function get($key, $default = null)
    {
        return $this->_cache->get($key,$default);
    }
    public function set($key, $value, $ttl = null)
    {
        return $this->_cache->set($key, $value,$ttl);
    }
    public function delete($key)
    {
        return $this->_cache->delete($key);
    }
    public function clear()
    {
        return $this->_cache->clear();
    }
    public function getMultiple($keys, $default = null)
    {
        return $this->_cache->getMultiple($keys, $default);
    }
    public function setMultiple($values, $ttl = null)
    {
        return $this->_cache->setMultiple($values, $ttl);
    }
    public function deleteMultiple($keys)
    {
        return $this->_cache->deleteMultiple($keys);
    }
    public function has($key)
    {
        return $this->_cache->has($key);
    }

}

