Server : Apache System : Linux iZ2vcgyutqttsd1p850kl8Z 3.10.0-1160.92.1.el7.x86_64 #1 SMP Tue Jun 20 11:48:01 UTC 2023 x86_64 User : www ( 1000) PHP Version : 5.6.40 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /www/wwwroot/saimikebio.com/mobile/include/kernel/cache/ |
<?php // +---------------------------------------------------------------------- // | EcTouch [ 专注移动电商: 商创网络科技 ] // +---------------------------------------------------------------------- // | Copyright (c) 2014 http://ectouch.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: EcTouch Team <zhong@ecmoban.com> (QQ: 2880175560) // +---------------------------------------------------------------------- class EcMemcache { private $mmc = NULL; private $group = ''; private $ver = 0; public function __construct($memConfig = array()) { $this->mmc = new Memcache; if (empty($memConfig)) { $memConfig['MEM_SERVER'] = array(array('127.0.0.1', 11211)); $memConfig['MEM_GROUP'] = ''; } foreach ($memConfig['MEM_SERVER'] as $config) { call_user_func_array(array($this->mmc, 'addServer'), $config); } $this->group = $memConfig['MEM_GROUP']; $this->ver = intval($this->mmc->get($this->group . '_ver')); } //读取缓存 public function get($key) { return $this->mmc->get($this->group . '_' . $this->ver . '_' . $key); } //设置缓存 public function set($key, $value, $expire = 1800) { return $this->mmc->set($this->group . '_' . $this->ver . '_' . $key, $value, 0, $expire); } //自增1 public function inc($key, $value = 1) { return $this->mmc->increment($this->group . '_' . $this->ver . '_' . $key, $value); } //自减1 public function des($key, $value = 1) { return $this->mmc->decrement($this->group . '_' . $this->ver . '_' . $key, $value); } //删除 public function del($key) { return $this->mmc->delete($this->group . '_' . $this->ver . '_' . $key); } //全部清空 public function clear() { return $this->mmc->set($this->group . '_ver', $this->ver + 1); } }