当前位置: 首页>>代码示例>>PHP>>正文


PHP memcache_set函数代码示例

本文整理汇总了PHP中memcache_set函数的典型用法代码示例。如果您正苦于以下问题:PHP memcache_set函数的具体用法?PHP memcache_set怎么用?PHP memcache_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了memcache_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
}
开发者ID:mesfreeman,项目名称:ifreeweixin,代码行数:32,代码来源:loginCookie.php

示例2: db_mysqli_query_fetch_list

function db_mysqli_query_fetch_list($mysqli, $query, $MYSQLI_TYPE)
{
    $config = getConfig();
    $params = $config['memcache'];
    $memcache = memcache_connect($params['host'], $params['port']);
    $memcacheQueryKey = 'QUERY' . $query['slow'];
    $data = memcache_get($memcache, $memcacheQueryKey);
    if (!empty($data)) {
    } else {
        if (!empty($query['fast'])) {
            $result = mysqli_query($mysqli, $query['fast']);
        } else {
            $result = mysqli_query($mysqli, $query['slow']);
        }
        $data = [];
        while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
            $data[] = $row;
        }
        //another proc
        /* $pid = pcntl_fork();
           if ($pid == 0) {*/
        memcache_set($memcache, $memcacheQueryKey, $data, 0, 60 * 10);
        /*    posix_kill(posix_getpid(), SIGTERM);
              }*/
    }
    memcache_close($memcache);
    return $data;
}
开发者ID:fedotovaleksandr,项目名称:vkTest,代码行数:28,代码来源:db_mysqli_query_fetch_list.php

示例3: set

 public function set($key, $value)
 {
     $this->check();
     if (memcache_set($this->connection, $key, $value, 0, Config::Get('cache_time')) === false) {
         throw new CacheException("Couldn't store data in cache");
     }
 }
开发者ID:jkinner,项目名称:ringside,代码行数:7,代码来源:CacheMemcache.php

示例4: set

 public static function set($key, $value, $name = 'default')
 {
     if (!App::instance()->get('cache_enable')) {
         return FALSE;
     }
     $client = self::client($key, $name);
     $ndx = self::$prefix . '_' . $key;
     $time = microtime(TRUE);
     // if ($cached = self::exist($key)){
     //     list($time, $ttl) = $cached;
     // }
     $data = App::instance()->serialize(array($value, $time, self::$ttl));
     switch (self::$engine) {
         case 'apc':
             return apc_store($ndx, $data, self::$ttl);
         case 'redis':
             // return $client->set($ndx, $data, array('ex' => self::$ttl));
             if (self::$ttl > 0) {
                 return $client->setex($ndx, self::$ttl, $data);
             } else {
                 return $client->set($ndx, $data);
             }
             break;
         case 'memcache':
             return memcache_set($client, $ndx, $data, 0, self::$ttl);
             break;
         default:
             return App::instance()->write($client . DS . $ndx, $data);
     }
     return FALSE;
 }
开发者ID:willsky,项目名称:quick,代码行数:31,代码来源:cache.php

示例5: setItem

 public function setItem($key, $value)
 {
     if (empty($key)) {
         throw new CacheException('CACHE ERROR:key is empty');
     }
     return memcache_set($this->cache, $key, $value, self::COMP, $this->ttl);
 }
开发者ID:tiger2soft,项目名称:LycPHP,代码行数:7,代码来源:Memcache.class.php

示例6: requeue_snapshot

 public function requeue_snapshot()
 {
     ignore_user_abort(true);
     header("Connection: Close");
     flush();
     ob_end_flush();
     $m = memcache_connect('127.0.0.1', 11211);
     $urlkey = sha1($this->snapshot_url);
     if (isset($_GET['requeue']) && 'true' != $_GET['requeue']) {
         if (memcache_get($m, $urlkey)) {
             die;
         }
     }
     memcache_set($m, $urlkey, 1, 0, 300);
     $requeue_url = self::renderer . "/queue?url=" . rawurlencode($this->snapshot_url) . "&f=" . urlencode($this->snapshot_file);
     $retval = file_get_contents($requeue_url);
     $tries = 1;
     while (false === $retval && $tries <= 5) {
         sleep(1);
         // in the event that the failed call is due to a mShots.js service restart,
         // we need to be a little patient as the service comes back up
         $retval = file_get_contents($requeue_url);
         $tries++;
     }
 }
开发者ID:nexusthemes,项目名称:mShots,代码行数:25,代码来源:class-mshots.php

示例7: removeObserver

 public function removeObserver($conn)
 {
     if (isset($conn->token)) {
         $token = $conn->token;
         if (defined("PUBSUB_CHANNEL")) {
             $observers = memcache_get($this->mmc, 'channel.observers.' . (string) $token->user_id);
             if (!empty($observers)) {
                 $observers = unserialize($observers);
                 foreach ($observers as $key => $value) {
                     if ($conn->_connection_identifier == $value->_connection_identifier) {
                         unset($observers[$key]);
                         memcache_set($this->mmc, 'channel.observers.' . (string) $token->user_id, serialize($observers));
                         return true;
                     }
                 }
             }
         } else {
             if (isset($this->observers[(string) $token->user_id])) {
                 foreach ($this->observers[(string) $token->user_id] as $key => $value) {
                     if ($conn == $value) {
                         unset($this->observers[(string) $token->user_id][$key]);
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:torry21th,项目名称:OCDServer,代码行数:29,代码来源:sub_manager.php

示例8: pmxCachePut

 function pmxCachePut($key, $value, $ttl, $useMember = false, $cleaner = null)
 {
     global $PortaMx_cache, $user_info, $mcache;
     $st = microtime(true);
     $ckey = $PortaMx_cache['key'] . ($useMember ? '-' . implode('_', $user_info['groups']) : '') . '-' . $key;
     if ($value !== null) {
         $value = serialize($value);
     } else {
         if ($cleaner !== null && $useMember) {
             $ckey = $PortaMx_cache['key'] . '-' . $cleaner . '-' . $key;
         }
     }
     // connected?
     if (empty($mcache)) {
         connect_mcache();
     }
     if ($mcache) {
         memcache_set($mcache, $ckey, $value, 0, $ttl);
         if ($value !== null) {
             $PortaMx_cache['vals']['saved'] += strlen($value);
         }
         $PortaMx_cache['vals']['time'] += microtime(true) - $st;
     }
     // handle member groups key?
     if ($useMember && $cleaner === null) {
         pmxCacheMemGroupAcs();
     }
 }
开发者ID:thunderamur,项目名称:PortaMx-Virgo-2.0-Beta-2,代码行数:28,代码来源:SubsCache.php

示例9: insert

 public function insert($key = '', $var = '', $time = 60, $compressed = false)
 {
     if ($compressed !== true) {
         $var = array($var, time(), $time);
     }
     return memcache_set($key, $var, 0, $time);
 }
开发者ID:bytemtek,项目名称:znframework,代码行数:7,代码来源:Memcache.php

示例10: pdb_get_data

function pdb_get_data($key, $provider, $arguments = [])
{
    $mc_handler = memcache_pconnect(MC_HOST);
    $value = memcache_get($mc_handler, $key);
    if ($value !== false) {
        return $value;
    } else {
        $locking_key = 'lock_' . $key;
        $locking_value = microtime(true);
        for ($i = 0; $i < MC_LOCK_DELAY * 1000 / MC_SLEEP_TIME + 1; $i++) {
            $lock = memcache_add($mc_handler, $locking_key, $locking_value, 0, MC_LOCK_DELAY);
            if ($lock) {
                $value = call_user_func_array($provider, $arguments);
                memcache_set($mc_handler, $key, $value);
                memcache_delete($mc_handler, $locking_key);
                return $value;
            } else {
                usleep(MC_SLEEP_TIME);
                $value = memcache_get($mc_handler, $key);
                if ($value != false) {
                    return $value;
                }
            }
        }
    }
    return call_user_func_array($provider, $arguments);
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:27,代码来源:db_cache_proxy.php

示例11: set

 /**
  *	Store value in cache
  *	@return mixed|FALSE
  *	@param $key string
  *	@param $val mixed
  *	@param $ttl int
  **/
 function set($key, $val, $ttl = 0)
 {
     $fw = Base::instance();
     if (!$this->dsn) {
         return TRUE;
     }
     $ndx = $this->prefix . '.' . $key;
     $time = microtime(TRUE);
     if ($cached = $this->exists($key)) {
         list($time, $ttl) = $cached;
     }
     $data = $fw->serialize(array($val, $time, $ttl));
     $parts = explode('=', $this->dsn, 2);
     switch ($parts[0]) {
         case 'apc':
         case 'apcu':
             return apc_store($ndx, $data, $ttl);
         case 'redis':
             return $this->ref->set($ndx, $data, array('ex' => $ttl));
         case 'memcache':
             return memcache_set($this->ref, $ndx, $data, 0, $ttl);
         case 'wincache':
             return wincache_ucache_set($ndx, $data, $ttl);
         case 'xcache':
             return xcache_set($ndx, $data, $ttl);
         case 'folder':
             return $fw->write($parts[1] . $ndx, $data);
     }
     return FALSE;
 }
开发者ID:eghojansu,项目名称:moe,代码行数:37,代码来源:Cache.php

示例12: set

 public function set($name, $data, $ttl = 86400)
 {
     if (!is_resource($this->memcache)) {
         throw new \Exception("Memcached can't connect.");
     }
     return memcache_set($this->memcache, $name, $data, 0, $ttl);
 }
开发者ID:glzaboy,项目名称:fastlib,代码行数:7,代码来源:sae.php

示例13: insert

 public function insert($key, $var, $time, $compressed)
 {
     if ($compressed !== true) {
         $var = [$var, time(), $time];
     }
     return memcache_set($key, $var, 0, $time);
 }
开发者ID:znframework,项目名称:znframework,代码行数:7,代码来源:Memcache.php

示例14: cache_set

function cache_set($key, $data, $expires)
{
    $connection = cache_connect();
    $res = memcache_set($connection, (string) $key, $data, false, (int) $expires);
    memcache_close($connection);
    return $res;
}
开发者ID:smarty-kiki,项目名称:frame,代码行数:7,代码来源:cache.php

示例15: setValue

 function setValue($key, $value, $expire = 0)
 {
     if ($expire == 0) {
         memcache_set($this->mmc, $key, $value);
     } else {
         memcache_set($this->mmc, $key, $value, $expire);
     }
 }
开发者ID:xuyintao,项目名称:thindev,代码行数:8,代码来源:Memcache.class.php


注:本文中的memcache_set函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。