當前位置: 首頁>>代碼示例>>PHP>>正文


PHP resource::set方法代碼示例

本文整理匯總了PHP中resource::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP resource::set方法的具體用法?PHP resource::set怎麽用?PHP resource::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在resource的用法示例。


在下文中一共展示了resource::set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: set

 function set($key, &$value)
 {
     if (!$this->_cache->set($key, $value, false, $this->_timeout)) {
         return false;
     }
     return true;
 }
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:7,代碼來源:Memcache.php

示例2: model

 /**
  * Load model
  *
  * @param string $model
  */
 public function model($model)
 {
     $file = DIR_BASE . 'application' . DIR_SEPARATOR . 'model' . DIR_SEPARATOR . $model . '.php';
     $class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
     if (file_exists($file)) {
         include_once $file;
         $this->registry->set('model_' . str_replace(DIR_SEPARATOR, '_', $model), new $class($this->registry));
     } else {
         trigger_error('Error: Could not load model ' . $file . '!');
         exit;
     }
 }
開發者ID:RustyNomad,項目名稱:bitsybay,代碼行數:17,代碼來源:loader.php

示例3: set

 /**
  * @param $key
  * @param $value
  *
  * @return bool
  */
 function set($key, &$value)
 {
     if (!$this->_cache->set($this->_prefix . $key, $value, FALSE, $this->_timeout)) {
         return FALSE;
     }
     return TRUE;
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:13,代碼來源:Memcache.php

示例4: store

	/**
	 * Store the data to memcache by id and group
	 *
	 * @access	public
	 * @param	string	$id		The cache data id
	 * @param	string	$group	The cache data group
	 * @param	string	$data	The data to store in cache
	 * @return	boolean	True on success, false otherwise
	 * @since	1.5
	 */
	function store($id, $group, $data)
	{
		$cache_id = $this->_getCacheId($id, $group);

		if (!$this->lockindex()) {
			return false;
		}

		$index = $this->_db->get($this->_hash.'-index');
		if ($index === false) {
			$index = array();
		}

		$tmparr = new stdClass;
		$tmparr->name = $cache_id;
		$tmparr->size = strlen($data);
		$index[] = $tmparr;
		
		$this->_db->replace($this->_hash.'-index', $index , 0, 0);
		$this->unlockindex();

		// prevent double writes, write only if it doesn't exist else replace
		if (!$this->_db->replace($cache_id, $data, $this->_compress, $this->_lifetime)) {
			$this->_db->set($cache_id, $data, $this->_compress, $this->_lifetime);
		}

		return true;
	}
開發者ID:raeldc,項目名稱:com_learn,代碼行數:38,代碼來源:memcache.php

示例5: write

 /**
  * Write
  *
  * Writes (create / update) session data
  *
  * @param	string	$session_id	Session ID
  * @param	string	$session_data	Serialized session data
  * @return	bool
  */
 public function write($session_id, $session_data)
 {
     if (!isset($this->_redis)) {
         return $this->_fail();
     } elseif ($session_id !== $this->_session_id) {
         if (!$this->_release_lock() or !$this->_get_lock($session_id)) {
             return $this->_fail();
         }
         $this->_key_exists = FALSE;
         $this->_session_id = $session_id;
     }
     if (isset($this->_lock_key)) {
         $this->_redis->setTimeout($this->_lock_key, 300);
         if ($this->_fingerprint !== ($fingerprint = md5($session_data)) or $this->_key_exists === FALSE) {
             if ($this->_redis->set($this->_key_prefix . $session_id, $session_data, $this->_config['expiration'])) {
                 $this->_fingerprint = $fingerprint;
                 $this->_key_exists = TRUE;
                 return $this->_success;
             }
             return $this->_fail();
         }
         return $this->_redis->setTimeout($this->_key_prefix . $session_id, $this->_config['expiration']) ? $this->_success : $this->_fail();
     }
     return $this->_fail();
 }
開發者ID:tastyigniter,項目名稱:tastyigniter,代碼行數:34,代碼來源:Session_redis_driver.php

示例6: set

 /**
  * @param $key
  * @param $value
  *
  * @return bool
  * @throws Exception
  */
 public function set($key, &$value)
 {
     if (!$this->_cache->set($this->_prefix . $key, serialize($value), $this->_timeout)) {
         CRM_Core_Error::debug('Result Code: ', $this->_cache->getResultMessage());
         CRM_Core_Error::fatal("Redis set failed, wondering why?, {$key}", $value);
         return FALSE;
     }
     return TRUE;
 }
開發者ID:FundingWorks,項目名稱:civicrm-core,代碼行數:16,代碼來源:Redis.php

示例7: _write

 /**
  * Writes session data to the memcache based session storage handler
  *
  * @param string $id The ID of the session
  * @param string $value The session data to store
  * @access protected
  */
 protected function _write($id, $value)
 {
     $id = 'sess_' . $id;
     if ($this->_conn->get($id)) {
         return $this->_conn->replace($id, $value, 0, $this->_life_time);
     } else {
         return $this->_conn->set($id, $value, 0, $this->_life_time);
     }
 }
開發者ID:heshuai64,項目名稱:gamestore,代碼行數:16,代碼來源:memcache.php

示例8: set

 /**
  * @param $key
  * @param $value
  *
  * @return bool
  * @throws Exception
  */
 function set($key, &$value)
 {
     $key = $this->cleanKey($key);
     if (!$this->_cache->set($key, $value, $this->_timeout)) {
         CRM_Core_Error::debug('Result Code: ', $this->_cache->getResultMessage());
         CRM_Core_Error::fatal("memcached set failed, wondering why?, {$key}", $value);
         return FALSE;
     }
     return TRUE;
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:17,代碼來源:Memcached.php

示例9: store

 /**
  * Adds the $var data to the cache under the key $key. Returns true or
  * false depending on the success of the operation.
  *
  * @param string $key
  * @param mixed $var
  * @param int $expire
  * @return bool
  */
 public function store($key, $var, $expire = 0)
 {
     if (strlen($key) > self::MAX_KEY_LENGTH) {
         throw new ezcCacheInvalidKeyException($key, 'Length > ' . self::MAX_KEY_LENGTH . '.');
     }
     // protect our data by wrapping it in an object
     $data = new ezcCacheMemoryVarStruct($key, $var, $expire);
     $compressed = $this->options->compressed === true ? MEMCACHE_COMPRESSED : false;
     return $this->memcache->set($key, $data, $compressed, $expire);
 }
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:19,代碼來源:memcache_backend.php

示例10: _setMemcache

 /**
  * 寫入緩存,使用pecl-memcache
  *
  * @param array $set
  * @param array $policy
  * @access protected
  * @return boolean
  */
 protected function _setMemcache(array $set, array $policy = array())
 {
     $compressed = isset($policy['compressed']) ? $policy['compressed'] : $this->_default_policy['compressed'];
     $life_time = isset($policy['life_time']) ? $policy['life_time'] : $this->_default_policy['life_time'];
     while (list($key, $value) = each($set)) {
         if (!$this->_conn->set($key, $value, $compressed ? MEMCACHE_COMPRESSED : 0, $life_time)) {
             return false;
         }
     }
     return true;
 }
開發者ID:Debenson,項目名稱:openwan,代碼行數:19,代碼來源:memcached.php

示例11: _setExpire

 /**
  * Set expire time on each call since memcache sets it on cache creation.
  *
  * @access private
  *
  * @param string  $key   Cache key to expire.
  * @param integer $lifetime  Lifetime of the data in seconds.
  */
 public function _setExpire($key)
 {
     $lifetime = $this->max_lifetime;
     $expire = $this->_db->get($key . '_expire');
     // set prune period
     if ($expire + $lifetime < time()) {
         $this->_db->delete($key);
         $this->_db->delete($key . '_expire');
     } else {
         $this->_db->set($key . '_expire', time(), 0);
     }
 }
開發者ID:GameCrusherTechnology,項目名稱:HeroTowerServer,代碼行數:20,代碼來源:memcache.php

示例12: add

 /**
  * 增加緩存
  * @param string $key 緩存鍵
  * @param mixed $value 緩存值
  * @param int $time 緩存時間
  * @param bool $compress 是否啟用壓縮
  * @retrun bool
  */
 public function add($key, $value, $time = 0, $compress = MEMCACHE_COMPRESSED)
 {
     $key = DAGGER_MC_KEY_PREFIX . $key;
     defined('DAGGER_DEBUG') && BaseModelCommon::debug($value, "mc_add({$key}),ttl({$time})");
     if ($this->snowslide === true) {
         if (!$this->mc->add($key . self::CACHE_TIME_CTL, 1, $compress, $time)) {
             return false;
         }
         $ret = $this->mc->set($key, $value, $compress, $time + 86400);
     } else {
         return $this->mc->add($key, $value, $compress, $time);
     }
     return $ret;
 }
開發者ID:az0ne,項目名稱:diaoyu,代碼行數:22,代碼來源:BaseModelMemcache.php

示例13: write

 /**
  * Write session data to the SessionHandler backend.
  *
  * @param   string  $id            The session identifier.
  * @param   string  $session_data  The session data.
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since   11.1
  */
 public function write($id, $session_data)
 {
     $sess_id = 'sess_' . $id;
     if ($this->_db->get($sess_id . '_expire')) {
         $this->_db->replace($sess_id . '_expire', time());
     } else {
         $this->_db->set($sess_id . '_expire', time());
     }
     if ($this->_db->get($sess_id)) {
         $this->_db->replace($sess_id, $session_data);
     } else {
         $this->_db->set($sess_id, $session_data);
     }
     return;
 }
開發者ID:nogsus,項目名稱:joomla-platform,代碼行數:25,代碼來源:memcached.php

示例14: add

 /**
  * 增加緩存
  * @param string $key 緩存鍵
  * @param mixed $value 緩存值
  * @param int $time 緩存時間
  * @retrun bool
  */
 public function add($key, $value, $time = 0)
 {
     $this->startRunTime = microtime(true);
     $calls = 1;
     if ($this->native) {
         $ret = $this->mcd->add($key, $value, $time);
     } else {
         if ($ret = $this->mcd->add($this->_buildKey($key, 'TIME_CTL'), $value, $time)) {
             $ret = $this->mcd->set($key, $value, $time + 86400);
             $calls++;
         }
         $this->lastResultCode = $this->mcd->getResultCode();
         $this->lastResultMessage = $this->mcd->getResultMessage();
     }
     $this->_checkStats(__FUNCTION__, $calls);
     defined('DAGGER_DEBUG') && BaseModelCommon::debug($value, "mcd_add({$key}),ttl({$time})");
     return $ret;
 }
開發者ID:az0ne,項目名稱:diaoyu,代碼行數:25,代碼來源:BaseModelMemcached.php

示例15: openConnection

 /**
  * 打開到服務端的連接
  * @return void
  */
 protected function openConnection()
 {
     $address = self::$addressArray[array_rand(self::$addressArray)];
     if (self::$useSwoole) {
         $address = explode(':', $address);
         $this->swooleClient = new swoole_client(SWOOLE_SOCK_TCP);
         $this->swooleClient->set($this->swooleClientSets);
         if (!$this->swooleClient->connect($address[0], $address[1], self::TIME_OUT)) {
             exit("connect failed. Error: {$this->swooleClient->errCode}\n");
         }
     } else {
         $this->connection = stream_socket_client($address, $err_no, $err_msg);
         if (!$this->connection) {
             throw new Exception("can not connect to {$address} , {$err_no}:{$err_msg}");
         }
         stream_set_blocking($this->connection, true);
         stream_set_timeout($this->connection, self::TIME_OUT);
     }
 }
開發者ID:stonegithubs,項目名稱:swoole-JsonRPC,代碼行數:23,代碼來源:RpcClient.php


注:本文中的resource::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。