?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类, 感谢原作者分享。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

Dreamweaver Mac版
ビジュアル Web 開発ツール

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。
