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


PHP Memcache::get方法代码示例

本文整理汇总了PHP中Memcache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::get方法的具体用法?PHP Memcache::get怎么用?PHP Memcache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memcache的用法示例。


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

示例1: get

 /**
  * Get a value from cache
  *
  * @param string $p_sKey The Key
  * @return mixed
  */
 function get($p_sKey)
 {
     if ($this->_serverAdded === false) {
         $this->addServer('localhost');
     }
     return $this->_handler->get($p_sKey);
 }
开发者ID:revolveweb,项目名称:ppi-framework,代码行数:13,代码来源:Memcached.php

示例2: afterQuery

	public function afterQuery(Atomik_Model_Builder $builder, Atomik_Model_Modelset $modelSet)
	{
		$modelName = $builder->name;
		$primaryKeyName = $builder->getPrimaryKeyField()->name;
		$manager = $builder->getManager();
		$db = $manager->getDbInstance();
		$rows = array();
		
		$dataQuery = $db->q()->select()
				->from($builder->tableName)
				->where(array($primaryKeyName => null));
		
		foreach ($modelSet as $row) {
			$primaryKey = $row[$primaryKeyName];
			$key = $modelName . ':' . $primaryKey;
			
			if (($cached = $this->_memcache->get($key)) !== false) {
				// cache hit
				$rows[] = $cached;
				continue;
			}
			
			$data = $dataQuery->setParams(array($primaryKey))->execute()->fetch();
			$this->_memcache->set($key, $data);
			$rows[] = $data;
		}
		
		$modelSet->setData($rows);
	}
开发者ID:neronen,项目名称:tsoha-k11p4-atomik,代码行数:29,代码来源:Cacheable.php

示例3: _exists

 /**
  * @see Cache::_exists()
  */
 protected function _exists($key)
 {
     if (!$this->is_connected) {
         return false;
     }
     return $this->memcache->get($key) !== false;
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:10,代码来源:CacheMemcache.php

示例4: get

 public function get($key)
 {
     if (null === $this->memcache) {
         $this->connect();
     }
     return $this->memcache->get($key);
 }
开发者ID:php-yaoi,项目名称:php-yaoi,代码行数:7,代码来源:Memcache.php

示例5: get

 /**
  * get cache item with given key
  *
  * @param string $key
  * @return string|array
  */
 public function get($key)
 {
     if (empty($key)) {
         throw new InvalidArgumentException("\$key is empty");
     }
     return $this->memcache->get($key);
 }
开发者ID:Welvin,项目名称:stingle,代码行数:13,代码来源:MemcacheWrapper.class.php

示例6: read

	/**
	 * Read from cache.
	 * @param  string key
	 * @return mixed|NULL
	 */
	public function read($key)
	{
		$key = $this->prefix . $key;
		$meta = $this->memcache->get($key);
		if (!$meta) {
			return NULL;
		}

		// meta structure:
		// array(
		//     data => stored data
		//     delta => relative (sliding) expiration
		//     callbacks => array of callbacks (function, args)
		// )

		// verify dependencies
		if (!empty($meta[self::META_CALLBACKS]) && !NCache::checkCallbacks($meta[self::META_CALLBACKS])) {
			$this->memcache->delete($key, 0);
			return NULL;
		}

		if (!empty($meta[self::META_DELTA])) {
			$this->memcache->replace($key, $meta, 0, $meta[self::META_DELTA] + time());
		}

		return $meta[self::META_DATA];
	}
开发者ID:rinaldinoor,项目名称:scoreBoard,代码行数:32,代码来源:MemcachedStorage.php

示例7: _updateValue

 /**
  * Write a line to the logfile.
  * @param String $line
  */
 protected function _updateValue($message, $keyPostfix = "")
 {
     $key = $this->_getKey($keyPostfix);
     $value = $this->_memcache->get($key);
     $value .= self::VALUE_SEPARATOR . $message;
     $this->_memcache->set($key, $value, null, $this->_expiry);
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:11,代码来源:Memcache.php

示例8: checkCache

 function checkCache($check = 0, $in, $out, $set = 0)
 {
     $inOut = 'inOut_' . $in . '_' . $out;
     $memcache_obj = new Memcache();
     $memcache_obj->connect('127.0.0.1', 11211) or die("Could not connect");
     if ($check === 1) {
         $available = $memcache_obj->get($inOut);
         if (!$available) {
             $set = $this->superfastCheck(1, $in, $out);
             $memcache_obj->set($inOut, $set, false, 324);
             $available = $memcache_obj->get($inOut);
         }
     } elseif ($check === 2) {
         $memcache_obj->flush();
     } else {
         $set = $this->superfastCheck($in, $out);
         //var_dump($set);
         $memcache_obj->set($inOut, $set, false, 324);
         //echo $inOut;
         $available = $memcache_obj->get($inOut);
         //var_dump($memcache_obj->getStats());
     }
     //var_dump($available);
     $memcache_obj->close();
     return $available;
 }
开发者ID:Asgart,项目名称:testapi,代码行数:26,代码来源:cache.php

示例9: read

 /**
  * @param string $id - session id, must be valid hash
  * @return string
  */
 public static function read($id)
 {
     if (!self::isConnected() || !self::isValidId($id)) {
         return "";
     }
     $sid = self::getPrefix();
     if (!self::$isReadOnly) {
         $lockTimeout = 55;
         //TODO: add setting
         $lockWait = 59000000;
         //micro seconds = 60 seconds TODO: add setting
         $waitStep = 100;
         while (!self::$connection->add($sid . $id . ".lock", 1, 0, $lockTimeout)) {
             usleep($waitStep);
             $lockWait -= $waitStep;
             if ($lockWait < 0) {
                 CSecuritySession::triggerFatalError('Unable to get session lock within 60 seconds.');
             }
             if ($waitStep < 1000000) {
                 $waitStep *= 2;
             }
         }
     }
     self::$sessionId = $id;
     $res = self::$connection->get($sid . $id);
     if ($res === false) {
         $res = "";
     }
     return $res;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:34,代码来源:session_mc.php

示例10: __construct

 /**
  * Creates a new MemcacheAdapter object.
  */
 private function __construct()
 {
     if (!class_exists('Memcache')) {
         throw new SystemException('memcache support is not enabled.');
     }
     // init memcache
     $this->memcache = new Memcache();
     // add servers
     $servers = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHE_HOST));
     foreach ($servers as $server) {
         $server = StringUtil::trim($server);
         if (!empty($server)) {
             $host = $server;
             $port = 11211;
             // default memcache port
             // get port
             if (strpos($host, ':')) {
                 $parsedHost = explode(':', $host);
                 $host = $parsedHost[0];
                 $port = $parsedHost[1];
             }
             $this->memcache->addServer($host, $port, CACHE_SOURCE_MEMCACHE_USE_PCONNECT);
         }
     }
     // test connection
     $this->memcache->get('testing');
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:30,代码来源:MemcacheAdapter.class.php

示例11: get

 public function get($id)
 {
     if (($value = $this->memcache->get($id)) === false) {
         return null;
     }
     return $value;
 }
开发者ID:maximebf,项目名称:cachecache,代码行数:7,代码来源:Memcache.php

示例12: get

 public function get($key)
 {
     $status = $this->aerospike->get($this->getKey($key), $record);
     if ($status == \Aerospike::OK) {
         return $record['bins'];
     }
 }
开发者ID:mochaka,项目名称:laravel-aerospike-cache,代码行数:7,代码来源:AerospikeStore.php

示例13: read

 /**
  * Read values for a set of keys from cache
  *
  * @param array $keys list of keys to fetch
  * @return array list of values with the given keys used as indexes
  * @return boolean true on success, false on failure
  */
 protected function read(array $keys)
 {
     $_res = array();
     /*
     		$_keys = $lookup = array();
     		foreach ($keys as $k) {
     			$_k = sha1($k);
     			$_keys[] = $_k;
     			$lookup[$_k] = $k;
     		}
     		$res = $this->phpFastCache->get($_keys);
     		if(!$res){
     			return $res;
     		}
     		foreach ($res as $k => $v) {
     			$_res[$lookup[$k]] = $v;
     		} //*/
     foreach ($keys as $k) {
         $k = sha1($k);
         $_res[$k] = $this->phpFastCache->get($k);
         //$_res[$k]=unserialize($_res[$k]);
     }
     //dump($_res);
     return $_res;
 }
开发者ID:admpub,项目名称:MicroPHP,代码行数:32,代码来源:cacheresource.phpFastCache.php

示例14: run

 public function run($request)
 {
     if (!class_exists('Memcache')) {
         $this->msg("Memcache class does not exist. Make sure that the Memcache extension is installed");
     }
     $host = defined('MEMCACHE_HOST') ? MEMCACHE_HOST : 'localhost';
     $port = defined('MEMCACHE_PORT') ? MEMCACHE_PORT : 11211;
     $memcache = new Memcache();
     $connected = $memcache->connect($host, $port);
     if ($connected) {
         $this->msg("Server's version: " . $memcache->getVersion());
         $result = $memcache->get("key");
         if ($result) {
             $this->msg("Data found in cache");
         } else {
             $this->msg("Data not found in cache");
             $tmp_object = new stdClass();
             $tmp_object->str_attr = "test";
             $tmp_object->int_attr = 123;
             $tmp_object->time = time();
             $tmp_object->date = date('Y-m-d H:i:s');
             $tmp_object->arr = array(1, 2, 3);
             $memcache->set("key", $tmp_object, false, 10);
         }
         $this->msg("Store data in the cache (data will expire in 10 seconds)");
         $this->msg("Data from the cache:");
         echo '<pre>';
         var_dump($memcache->get("key"));
         echo '</pre>';
     } else {
         $this->msg("Failed to connect");
     }
 }
开发者ID:lekoala,项目名称:silverstripe-devtoolkit,代码行数:33,代码来源:TestMemcacheTask.php

示例15: get

 /**
  * Pobranie wartości z cache
  *
  * @param string $module
  * @param string $property
  * @return mixed
  */
 function get($module, $property)
 {
     $tKey = $this->getKey($module, $property);
     if (!isset($this->internalCache[$tKey])) {
         $this->internalCache[$tKey] = $this->memcached->get($tKey);
     }
     return $this->internalCache[$tKey];
 }
开发者ID:PhanQuocTrung,项目名称:raspberry_temperature_log,代码行数:15,代码来源:Memcached.php


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