36 lines
833 B
PHP
36 lines
833 B
PHP
|
|
<?php
|
||
|
|
class Vtiger_Cache_Connector {
|
||
|
|
private static $instance = null;
|
||
|
|
private $cache = [];
|
||
|
|
|
||
|
|
private function __construct() {}
|
||
|
|
|
||
|
|
public static function getInstance() {
|
||
|
|
if (self::$instance === null) {
|
||
|
|
self::$instance = new self();
|
||
|
|
}
|
||
|
|
return self::$instance;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function get($ns, $key) {
|
||
|
|
return isset($this->cache[$ns][$key]) ? $this->cache[$ns][$key] : false;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function set($ns, $key, $value) {
|
||
|
|
if (!isset($this->cache[$ns])) {
|
||
|
|
$this->cache[$ns] = [];
|
||
|
|
}
|
||
|
|
$this->cache[$ns][$key] = $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function delete($ns, $key) {
|
||
|
|
if (isset($this->cache[$ns][$key])) {
|
||
|
|
unset($this->cache[$ns][$key]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function flush() {
|
||
|
|
$this->cache = [];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|