?php/** 2012-12-04 14:54* @author 孤独求学人*/class php_memcache{protected $handle = null;protected $mem = null;private $host = "";private $port = "";private $timeout = 0;private $pconnect = false;public function __construct($host = '127.0
<?php /* * 2012-12-04 14:54 * @author 孤独求学人 */ class php_memcache{ protected $handle = null; protected $mem = null; private $host = ""; private $port = ""; private $timeout = 0; private $pconnect = false; public function __construct($host = '127.0.0.1',$port='11211',$timeout=0,$pconnect=false){ $this->host = $host; $this->port = $port; $this->timeout = $timeout; $this->pconnect = $pconnect; $this->mem = new Memcache(); } public function connect(){ if(!is_resource($this->handle)) { if($this->pconnect == false){ if(empty($this->host)){ return false; } if(empty($this->port)){ return false; } $handle = $this->mem->connect($this->host,$this->port); if(!$handle){ return false; }else{ $this->handle = $handle; } } } return $this->handle; } public function set($key,$val,$flag=false,$expire=0){ if(!$this->connect()) return false; $iFlage = 0; if($flag == true){ $iFlage = MEMCACHE_COMPRESSED; } return $this->mem->set($key,$val,$iFlage,$expire); } public function get($key){ if(!$this->connect()) return false; if (is_array($key)) { $dest = array(); foreach ($key as $subkey) { $val = $this->get($subkey); if (!($val === false)){ $dest[$subkey] = $val; } } return $dest; } else { return $this->mem->get($key); } } public function replace($key,$val,$flag=false,$expire=0){ if(!$this->connect()) return false; $iFlage = 0; if($flag == true){ $iFlage = MEMCACHE_COMPRESSED; } return $this->mem->replace($key,$val,$iFlage,$expire); } public function delete($key,$time=0){ if(!$this->connect()) return false; return $this->mem->delete($key,$time); } public function flush(){ if(!$this->connect()) return false; return $this->mem->flush(); } public function incr($key,$val=1){ if(!$this->connect()) return false; return $this->mem->increment($key,$val); } public function decr($key,$val=1){ if(!$this->connect()) return false; return $this->mem->decrement($key,$val); } public function getVersion(){ if(!$this->connect()) return false; return $this->mem->getVersion(); } } ?>
原文地址:php memcache类, 感谢原作者分享。
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
刺客信條陰影:貝殼謎語解決方案
2 週前ByDDD
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Dreamweaver Mac版
視覺化網頁開發工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。