2
为了使用Memcached,我是否必须修改应用程序中的每个查询?如何使用PDO实现Memcached
我使用这个DB类与PDO教程:
class DB {
private static $host;
private static $dbName;
private static $user;
private static $password;
/*** Declare instance ***/
private static $instance = NULL;
/**
*
* the constructor is set to private so
* so nobody can create a new instance using new
*
*/
private function __construct() {}
/**
*
* Return DB instance or create intitial connection
* @return object (PDO)
* @access public
*
*/
public static function getInstance() {
if (!self::$instance){
self::$instance = new PDO("mysql:host=".self::$host.";dbname=".self::$dbName, self::$user, self::$password);
self::$instance-> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
return self::$instance;
}
/**
*
* Like the constructor, we make __clone private
* so nobody can clone the instance
*
*/
private function __clone(){}
} /*** end of class ***/
是否有修改它纳入Memcached的一个很好的简单的方法?
可能的重复[如何设计使用PDO和memcached的高速缓存系统?](http://stackoverflow.com/questions/2600720/how-i-can-design-a-cache-system-using-pdo-and-memcached) – RobertPitt 2010-12-07 13:53:18
@Robert我读过那个问题及其链接,这些都没有帮助我。 – bcmcfc 2010-12-07 14:33:13