2017-02-03 21:54:17 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
|
|
|
* This is NOT a freeware, use is subject to license terms
|
|
|
|
*
|
|
|
|
* $Id: memory_driver_apc.php 27635 2012-02-08 06:38:31Z zhangguosheng $
|
|
|
|
*/
|
|
|
|
if (!defined('IN_DISCUZ')) {
|
2017-02-07 21:41:52 -05:00
|
|
|
exit('Access Denied');
|
2017-02-03 21:54:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
class memory_driver_apcu {
|
|
|
|
|
2017-02-07 23:41:58 -05:00
|
|
|
public $cacheName = 'APCu';
|
|
|
|
public $enable;
|
2017-02-12 22:43:46 -05:00
|
|
|
|
2017-02-07 23:41:58 -05:00
|
|
|
public function env() {
|
|
|
|
return function_exists('apcu_cache_info') && @apcu_cache_info();
|
|
|
|
}
|
2017-02-12 22:43:46 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function init($config) {
|
2017-02-07 23:41:58 -05:00
|
|
|
$this->enable = $this->env();
|
2017-02-07 21:41:52 -05:00
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function get($key) {
|
|
|
|
return apcu_fetch($key);
|
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function set($key, $value, $ttl = 0) {
|
|
|
|
return apcu_store($key, $value, $ttl);
|
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function rm($key) {
|
|
|
|
return apcu_delete($key);
|
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function clear() {
|
|
|
|
return apcu_clear_cache('user');
|
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function inc($key, $step = 1) {
|
|
|
|
return apcu_inc($key, $step) !== false ? apcu_fetch($key) : false;
|
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-07 21:41:52 -05:00
|
|
|
public function dec($key, $step = 1) {
|
|
|
|
return apcu_dec($key, $step) !== false ? apcu_fetch($key) : false;
|
|
|
|
}
|
2017-02-03 21:54:17 -05:00
|
|
|
|
2017-02-12 22:43:46 -05:00
|
|
|
}
|