使用 memcached 的 PHP 扩展
我正在考虑编写一个将使用 memcached 库的 PHP 扩展库。只需将我的库链接到 memcache shlib 就很简单了。
但是,我不确定如果我的(扩展库)用户已经在他/她的网站上使用了 memcache,会发生什么。我的问题是:
- 机器上是否可以有(可能是不同版本的)memcache?
- 构建扩展库时是静态链接还是动态链接到memcache最好? (为了解决版本不兼容性 - 假设 memcache 向后兼容,否则所有的赌注都会被取消)
这些问题基本上退化为如果一个扩展库依赖于可能已经在使用的第三方文件,那么如何保护他们编写的扩展库在要使用扩展库的网站上?
这个问题可能有点不恰当,但我希望你能理解我所问的要点。
I am thinking of writing a PHP extension library that will use the memcached library. It is trivial to simply link my library to the memcache shlib.
However, I am not sure what will happen if my (extension library) user already uses memcache on his/her website. My questions are:
- Is it possible to have (possibly different versions) of memcache on the machine?
- Is it best to statically link or dynamically link to memcache when building the extension library? (to cater for version incompatibilities - assuming memcache is backward compatible, otherwise all bets are off)
The questions basically degenerate to how may one safeguard an extension library they have written if it has a dependence on a third party file which may already be being used on the website that the extension library is going to be used on?
The question may probably be slightly ill-posed, but I hope you understand the gist of what I am asking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,PHP 有两个 memcache 扩展,一个称为 memcache,另一个称为 memcached,第一个使用它自己的 memcache 协议实现,后者使用该库。
如果您使用第一个,则不应该发生冲突,但必须自己处理内存缓存。我建议构建一个依赖于 memcached 的扩展并重新使用它找到的库。
Mind that there are two memcache extensions for PHP, one is called memcache, the other memcached, the first uses it's own implementation of the memcache protocol, the later uses the library.
If you're using the first you shouldn't have a conflcit but have to take care of memcache on your own. I'd suggest building an extension which depends on the memcached and re uses the library it found.