当前位置: 首页>>代码示例>>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;未经允许,请勿转载。