<?php
/**
  * memcache.class.php
  * Memcache efficient cache commonly used types 
  * @category No
  *
  * @author Tao <[email protected] >
  * @copyright Copyright© 2004-2008 Njbear.Com Inc All Rights Reserved.
  * @license http://www.njbear.com/ Private-source licence 0.1
  * @version 0.1
  * @example $Cache = new Cache(new memcache);
  */
class Cache
{
 private $memcachedBloom = false;
 public  $memcache = '';
 
 const   SEVER  = '127.0.0.1';
 
 function __construct($memcache)
 {
  $this->memcache = $memcache;
  $this->memcache->connect( self::SEVER , 11211) or die ("连接失败");
 }
 /**
  * 设置缓存
  *
  * @param 缓存名称 $key
  * @param 值 $value
  * @param 设置时间 $time
  */
 public function set($key , $value , $time)
 {
  $this->memcache->set($key , $value , $this->memcachedBloom ,  $time);
 }
 /**
  * 得到指定的缓存
  *
  * @param 键 $key
  * @return 缓存值
  */
 public function  get($key)
 {
  return $this->memcache->get($key);
 }
 /**
  * 清除所有数据
  *
  */
 public function flush()
 {
  $this->memcache->flush();
 }
 /**
  * 关闭memcache
  *
  */
 public function close()
 {
  $this->memcache->close();
 }
 /**
  * 替换数据
  *
  * @param 要替换的键名 $key
  * @param 替换数据 $data
  * @param 替换时间 $time
  */
 public function replace($key , $data , $time)
 {
  $this->memcache->replace($key, $data, $this->memcachedBloom , $time);
 }
 /**
  * 删除指定缓存
  *
  * @param 缓存键名 $key
  */
 public function delete($key)
 {
  $this->memcache->delete($key);
 }
 function __destruct(){}
}
?>