DiscuzX/upload/source/class/memory/memory_driver_yac.php

63 lines
1.1 KiB
PHP
Raw Normal View History

2017-02-02 04:22:13 -05:00
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: memory_driver_yac.php 27635 2017-02-02 17:02:46Z NaiXiaoxIN $
*/
2017-02-03 21:54:17 -05:00
if (!defined('IN_DISCUZ')) {
2017-02-02 04:22:13 -05:00
exit('Access Denied');
}
2017-02-03 21:54:17 -05:00
class memory_driver_yac {
2017-02-02 04:22:13 -05:00
2017-02-03 21:54:17 -05:00
private $object = null;
2017-02-02 04:22:13 -05:00
public function init($config) {
2017-02-03 21:54:17 -05:00
$this->object = new yac();
2017-02-02 04:22:13 -05:00
}
public function get($key) {
return $this->object->get($key);
}
public function getMulti($keys) {
2017-02-03 21:54:17 -05:00
$result = $this->object->get($keys);
foreach ($result as $key => $value) {
if ($value === false) {
unset($result[$key]);
}
}
return $result;
2017-02-02 04:22:13 -05:00
}
public function set($key, $value, $ttl = 0) {
return $this->object->set($key, $value, $ttl);
}
public function rm($key) {
2017-02-03 21:54:17 -05:00
return $this->object->delete($key);
2017-02-02 04:22:13 -05:00
}
public function clear() {
return $this->object->flush();
}
public function inc($key, $step = 1) {
2017-02-03 21:54:17 -05:00
$old = $this->get($key);
if (!$old) {
return false;
}
return $this->set($key, $old + $step);
2017-02-02 04:22:13 -05:00
}
public function dec($key, $step = 1) {
2017-02-03 21:54:17 -05:00
$old = $this->get($key);
if (!$old) {
return false;
}
return $this->set($key, $old - $step);
2017-02-02 04:22:13 -05:00
}
2017-02-03 21:54:17 -05:00
}