php简单的Memcache单例模式类

<?php
/*
php简单的Memcache单例模式类
*/
class mCache {
static protected $m;
static public function getCache() {
if (self::$m) {
return self::$m;
}
self::$m = new Memcache;
self::$m->connect('localhost', 11211);
return self::$m;
}
}
//使用方法
// 获取实例
$cache = mCache::getCache();
$key = 'key_name';
$content = array('this is an array','of strings');
$cache->set($key, serialize($content));
$returnContent = $cache->get($key);
var_dump($returnContent);