colly_wyx
2018-05-18 50a53f7db63c5729b0ddbc93367117cf35ccf03c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
 * PhalApi_Cache_APCU    APC User Cache 
 *
 * @package     PhalApi\Cache
 * @license     http://www.phalapi.net/license GPL 协议
 * @link        http://www.phalapi.net/
 * @author      dogstar <chanzonghuang@gmail.com> 2017-04-14
 */
 
class PhalApi_Cache_APCU {
 
    public function __construct() {
        if (!extension_loaded('apcu')) {
            throw new PhalApi_Exception_InternalServerError(
                T('missing {name} extension', array('name' => 'apcu'))
            );
        }
    }
 
    public function set($key, $value, $expire = 600) {
        return apcu_store($key, $value, $expire);
    }
 
    public function get($key) {
        $value = apcu_fetch($key);
        return $value !== FALSE ? $value : NULL;
    }
 
    public function delete($key) {
        return apcu_delete($key);
    }
}