本文整理汇总了PHP中memcache_init函数的典型用法代码示例。如果您正苦于以下问题:PHP memcache_init函数的具体用法?PHP memcache_init怎么用?PHP memcache_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memcache_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->_memcached = memcache_init();
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$this->_prefixKey = $path == '' ? 'system_cache_' : $path;
}
示例2: get_channel_url
function get_channel_url($uid = null)
{
if (!is_login()) {
return false;
}
/*
$channel = new SaeChannel();
$channel_name = 'NowBoard';
$duration = 3600;
$url = $channel->createChannel( wbuid().'.'.$channel_name,$duration);
*/
if ($uid == null) {
$uid = wbuid();
}
$urlkey = 'nowboard-url-all';
$mc = memcache_init();
if (!($url = $mc->get($urlkey))) {
$channel = new SaeChannel();
$channel_name = $urlkey;
$duration = 3600;
$url = $channel->createChannel($channel_name, $duration);
$mc->set($urlkey, $url, 0, 3600);
}
return $url;
}
示例3: _display_cache
/**
* Update/serve a cached file
*
* @access public
* @param object config class
* @param object uri class
* @return void
*/
function _display_cache(&$CFG, &$URI)
{
$cache_adapter;
$cach_model = $CFG->item('sae_output_cache');
$status;
switch ($cach_model) {
case '':
return FALSE;
break;
case 'kvdb':
$cache_adapter = new SaeKV();
$status = $cache_adapter->init();
break;
case 'memcache':
$cache_adapter = memcache_init();
$status = $cache_adapter;
break;
}
if (!$status) {
return FALSE;
}
$uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
$cache_key = md5($uri);
$cache = $cache_adapter->get($cache_key);
if ($cache === FALSE) {
//缓存已过期
log_message('debug', "Cache has expired.");
return FALSE;
} else {
//输出缓存
log_message('debug', "Cache is current. Sending it to browser.");
$this->_display($cache);
return TRUE;
}
}
示例4: getRights
private function getRights()
{
$gid = (int) $_COOKIE['gid'];
$cacheName = "action_code_group_" . $gid;
/*$cache = memcache_init();
//$cache->init ( array ("dir" => SlightPHP::$appDir . "/cache", "depth" => 3 ) );
$rs = $cache->get ( $cacheName );
if ($cache and $rs) {
} else {
$rsObj = base_mAPI::get ( 'm_group', $gid );
$rs = $rsObj->get ();
$cache->set ( $cacheName, $rs );
}*/
$rsObj = base_mAPI::get('m_group', $gid);
$rs = $rsObj->get();
$action = unserialize($rs['action_code']);
$mc = memcache_init();
$head_title = $mc->get($_SERVER['HTTP_APPVERSION'] . "head_title");
if (!$head_title) {
$modelObj = new base_m();
$rs = $modelObj->_db->selectOne(base_Constant::TABLE_PREFIX . "system", "", "sysname");
$head_title = $rs['rsystem_name'];
$mc->set($_SERVER['HTTP_APPVERSION'] . "head_title", $head_title);
}
$this->params['head_title'] = $head_title;
$this->params['menu'] = $action['menu'];
$this->params['_userid'] = $_COOKIE['admin_id'];
$this->params['_adminname'] = $_COOKIE['admin_name'];
}
示例5: __construct
function __construct($configs)
{
$this->cache = \memcache_init();
if ($this->cache === false) {
throw new \Exception("SaeMemcache init fail", 1);
}
}
示例6: __construct
/**
* 构造函数,进行模板引擎的实例化操作
*/
public function __construct()
{
if (FALSE == $GLOBALS['G_SP']['view']['enabled']) {
return FALSE;
}
if (FALSE != $GLOBALS['G_SP']['view']['auto_ob_start']) {
ob_start();
}
$this->engine = spClass($GLOBALS['G_SP']['view']['engine_name'], null, $GLOBALS['G_SP']['view']['engine_path']);
if ($GLOBALS['G_SP']['view']['config'] && is_array($GLOBALS['G_SP']['view']['config'])) {
$engine_vars = get_class_vars(get_class($this->engine));
foreach ($GLOBALS['G_SP']['view']['config'] as $key => $value) {
if (array_key_exists($key, $engine_vars)) {
$this->engine->{$key} = $value;
}
}
}
if (!empty($GLOBALS['G_SP']['sp_app_id']) && isset($this->engine->compile_id)) {
$this->engine->compile_id = $GLOBALS['G_SP']['sp_app_id'];
}
if (empty($this->engine->no_compile_dir)) {
memcache_init();
}
spAddViewFunction('T', array('spView', '__template_T'));
spAddViewFunction('spUrl', array('spView', '__template_spUrl'));
}
示例7: getLoginCookie
function getLoginCookie($openid)
{
//数据库操作
require_once 'utils/Mysql.class.php';
$class_mysqlObj = new Class_mysql();
$sql_state = "select studentid,IdCard from tb_studentInfo where openid='{$openid}'";
$studentInfoArr = $class_mysqlObj->query_array($sql_state);
//取出数据库里的 学号与身份证号
$studentid = $studentInfoArr[0]['studentid'];
$IdCard = $studentInfoArr[0]['IdCard'];
//创建临时文件
$cookieFile = SAE_TMP_PATH . '/personInfo_cookie.txt';
$IdCardNum = substr($IdCard, 11, 6);
if (strlen($IdCard) == 15) {
$IdCardNum = substr($IdCard, 9, 6);
}
$login_url = "http://my.hpu.edu.cn/userPasswordValidate.portal";
$login = "Login.Token1={$studentid}&Login.Token2={$IdCardNum}&goto=http%3A%2F%2Fmy.hpu.edu.cn%2FloginSuccess.portal&gotoOnFail=http%3A%2F%2Fmy.hpu.edu.cn%2FloginFailure.portal";
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $login);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
// 把返回来的cookie信息保存在文件中
curl_exec($ch);
curl_close($ch);
//读取文件内容
$personInfo_cookie = file_get_contents($cookieFile);
$mmc = memcache_init();
// 初始化缓存
memcache_set($mmc, $openid . "personInfo_cookie", $personInfo_cookie, 0, 600);
return $personInfo_cookie;
}
示例8: __construct
public function __construct()
{
$this->mem = memcache_init();
if (false === $this->mem) {
throw new Gloft_Driver_Cache_Exception("memcached server init error");
}
}
示例9: send
public static function send($msg, $detail, $level = self::USER, $mobile = null)
{
//判断是否定义需要发送短信
if (!in_array($level, explode(',', C('SMS_LEVEL')))) {
return;
}
//判断发送频率
$mc = memcache_init();
$is_send = $mc->get('think_sms_send');
//如果已经发送,则不发送
if ($is_send === 'true') {
$status = 'not send';
} else {
//TODU,如果apibus类调整,此类也得调整
$sms = apibus::init('sms');
if (is_null($mobile)) {
$mobile = C('SMS_MOBILE');
}
$mc = memcache_init();
$obj = $sms->send($mobile, mb_substr(C('SMS_SIGN') . $msg, 0, 65, 'utf-8'), "UTF-8");
if ($sms->isError($obj)) {
$status = 'failed';
} else {
$status = 'success';
$mc->set('think_sms_send', 'true', 0, C('SMS_INTERVAL'));
}
}
//记录日志
if (C('LOG_RECORD')) {
Log::record($msg . ';detail:' . $detail . '【status:' . $status . '】', 'SEND_SMS', true);
} else {
Log::write($msg . ';detail:' . $detail . '【status:' . $status . '】', 'SEND_SMS');
}
}
示例10: sp_clear_cache
/**
* 清空缓存
*/
function sp_clear_cache()
{
import("ORG.Util.Dir");
$dirs = array();
// runtime/
$rootdirs = scandir(RUNTIME_PATH);
//$noneed_clear=array(".","..","Data");
$noneed_clear = array(".", "..");
$rootdirs = array_diff($rootdirs, $noneed_clear);
foreach ($rootdirs as $dir) {
if ($dir != "." && $dir != "..") {
$dir = RUNTIME_PATH . $dir;
if (is_dir($dir)) {
array_push($dirs, $dir);
$tmprootdirs = scandir($dir);
foreach ($tmprootdirs as $tdir) {
if ($tdir != "." && $tdir != "..") {
$tdir = $dir . '/' . $tdir;
if (is_dir($tdir)) {
array_push($dirs, $tdir);
}
}
}
} else {
@unlink($dir);
}
}
}
$dirtool = new Dir("");
foreach ($dirs as $dir) {
$dirtool->del($dir);
}
if (defined('IS_SAE') && IS_SAE) {
$global_mc = @memcache_init();
if ($global_mc) {
$global_mc->flush();
}
$no_need_delete = array("THINKCMF_DYNAMIC_CONFIG");
$kv = new SaeKV();
// 初始化KVClient对象
$ret = $kv->init();
// 循环获取所有key-values
$ret = $kv->pkrget('', 100);
while (true) {
foreach ($ret as $key => $value) {
if (!in_array($key, $no_need_delete)) {
$kv->delete($key);
}
}
end($ret);
$start_key = key($ret);
$i = count($ret);
if ($i < 100) {
break;
}
$ret = $kv->pkrget('', 100, $start_key);
}
}
}
示例11: getMemCache
public function getMemCache()
{
if ($this->_cache !== NULL) {
return $this->_cache;
} else {
return $this->_cache = $this->useMemcached ? new Memcached() : @memcache_init();
}
}
示例12: MoveToRoom
protected function MoveToRoom($strKey, $openID, $roomName)
{
$msg = $this->rooms[$roomName]->OnOpen($strKey, $openID);
$mc = memcache_init();
$mc->set($openID . 'room', $roomName, 0, 300);
//记录房间名
return $msg;
}
示例13: __construct
function __construct($config = array())
{
parent::__construct($config);
if (defined('IS_SAE')) {
$this->_mamcache = memcache_init() or trigger_error('Memcache Init Error', E_USER_ERROR);
} else {
$this->_mamcache = memcache_connect($this->host, $this->port) or trigger_error('Memcache Connect Error', E_USER_ERROR);
}
}
示例14: __construct
/**
* Create a new service repository instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string $manifestPath
* @return void
*/
public function __construct(Filesystem $files, $manifestPath)
{
$this->files = $files;
$this->manifestPath = $manifestPath;
$this->isSae = $this->detectSae();
if ($this->isSae) {
$this->memcache = memcache_init();
}
}
示例15: __construct
function __construct()
{
$this->mmc = memcache_init();
//Load filenames
$arr = self::get($this->fname_key);
if (is_array($arr)) {
$this->filenames = $arr;
}
}