shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

cache.php (1334B)


      1 <?php
      2 /**
      3  * @package		OpenCart
      4  * @author		Daniel Kerr
      5  * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
      6  * @license		https://opensource.org/licenses/GPL-3.0
      7  * @link		https://www.opencart.com
      8 */
      9 
     10 /**
     11 * Cache class
     12 */
     13 class Cache {
     14 	private $adaptor;
     15 	
     16 	/**
     17 	 * Constructor
     18 	 *
     19 	 * @param	string	$adaptor	The type of storage for the cache.
     20 	 * @param	int		$expire		Optional parameters
     21 	 *
     22  	*/
     23 	public function __construct($adaptor, $expire = 3600) {
     24 		$class = 'Cache\\' . $adaptor;
     25 
     26 		if (class_exists($class)) {
     27 			$this->adaptor = new $class($expire);
     28 		} else {
     29 			throw new \Exception('Error: Could not load cache adaptor ' . $adaptor . ' cache!');
     30 		}
     31 	}
     32 	
     33     /**
     34      * Gets a cache by key name.
     35      *
     36      * @param	string $key	The cache key name
     37      *
     38      * @return	string
     39      */
     40 	public function get($key) {
     41 		return $this->adaptor->get($key);
     42 	}
     43 	
     44     /**
     45      * 
     46      *
     47      * @param	string	$key	The cache key
     48 	 * @param	string	$value	The cache value
     49 	 * 
     50 	 * @return	string
     51      */
     52 	public function set($key, $value) {
     53 		return $this->adaptor->set($key, $value);
     54 	}
     55    
     56     /**
     57      * 
     58      *
     59      * @param	string	$key	The cache key
     60      */
     61 	public function delete($key) {
     62 		return $this->adaptor->delete($key);
     63 	}
     64 }