一个简单的PHP+memcache缓存类

class cache_memcache {

  private $memcache = null;

  public function __construct() {
    $this->memcache = new Memcache;
    $this->memcache->connect(MEMCACHE_HOST, MEMCACHE_PORT, MEMCACHE_TIMEOUT);
  }

  public function memcache() {
    $this->__construct();
  }

  public function get($name) {
    $value = $this->memcache->get($name);
    return $value;
  }

  public function set($name, $value, $ttl = 0, $ext1='', $ext2='') {
    return $this->memcache->set($name, $value, 0, $ttl);
  }

  public function delete($name) {
    return $this->memcache->delete($name);
  }

  public function flush() {
    return $this->memcache->flush();
  }
}

posted on 2011-05-20 13:07  dawnruby  阅读(201)  评论(0)    收藏  举报

导航