Home > php教程 > PHP源码 > 读取设置memcache的值(优先支持memcached扩展和cas协议)

读取设置memcache的值(优先支持memcached扩展和cas协议)

PHP中文网
Release: 2016-05-23 16:39:57
Original
1132 people have browsed it

          

addServer($INI['memcachehost'], $INI['memcacheport']);
				$res['value'] = $m1->get($key, null, $cas);
				$res['cas'] = $cas;
			}
			else
			{
				$m1 = self::getinstance();
				$m1->addServer($INI['memcachehost'], $INI['memcacheport']);
				$res['value'] = $m1->get($key);
			}
			return $res;
		}

		static public function set($key,$value,$cas)
		{
			$value = (string)$value;
			global $INI;
			if(class_exists('Memcached'))
			{
				$m1 = self::getinstance();
				$m1->addServer($INI['memcachehost'], $INI['memcacheport']);
				$res = $m1->cas($cas,$key,$value);
			}
			else
			{
				$m1 = self::getinstance();
				$m1->addServer($INI['memcachehost'], $INI['memcacheport']);
				$res = $m1->set($key,$value);
			}
			return $res;
		}
	}
Copy after login

                                   

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template