网上广泛流传着一篇文章,讲述php的两个扩展模块memcache和memcached的区别,其中特意强调了memcached与memcached一个很大的区别是memcached模块不支持长连接。以至于后来很多年我都认为memcached是不支持长连接的,其实不然,memcached扩展模块从很早的版本开始就已经支持长连接了。从扩展模块的源码注视中我们就能看到:/* {{{ Memcached::__construct([string persistent_id[, callback on_new[, string connection_str]]]))Creates a Memcached object, optionally using persistent memcache connection */static PHP_METHOD(Memcached, __construct){从php的手册身上我们可以看到memcached的扩展模块提供的构造函数提供一个参数persistent_id可选项,手册中这样介绍:默认情况下,Memcached实例在请求结束后会被销毁。但可以在创建时通过persistent_id为每个实例指定唯一的ID, 在请求间共享实例。所有通过相同的persistent_id值创建的实例共享同一个连接。这个参数的含义就是说如果你传递了一个命名i
...
继续阅读
(19)