用什么代替php 5.5中的apc用户数据缓存? [英] What to use instead of apc user data cache in php 5.5?

查看:93
本文介绍了用什么代替php 5.5中的apc用户数据缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP 5.5默认包含zend opcache,这基本上意味着几乎没有人会使用APC.

PHP 5.5 includes zend opcache by default, which basically means that almost nobody will use APC.

但是使用什么代替APC的用户数据缓存部分(apc_store和apc_fetch和类似)呢?

But what to use instead of the user data cache part of APC (apc_store & apc_fetch & similar)?

我非常喜欢使用APC用户数据缓存的一个用例是静态资产(javascript,css ..)的版本".每当我引用静态文件时,我都会将其内容的哈希值添加到url中(例如,< script src =/script.js>将变为< script src =/script.js?v = hash>),以便浏览器始终使用当前版本,并可以将其永久缓存.

One use case where I really like to use APC user data cache are "versions" of static assets (javascript, css..). Whenever I reference static file, I add hash of its content into the url (e.g. <script src=/script.js> will became <script src=/script.js?v=hash>), so that browser always uses current version and can cache it permanently.

我可以想象使用redis或memcache来存储静态文件的哈希值,但是通过网络或套接字请求另一个进程以获取文件内容的哈希值似乎很愚蠢. APC用户数据缓存(位于共享内存中,访问它的速度几乎与访问php变量一样快)似乎是对此类数据使用的正确选择.

I can imagine using redis or memcache to store the hashes of static files, but it seems silly to ask another process over network or socket just to get a hash of file content. APC user data cache (which is in shared memory and accessing it is almost as fast as accesing php variable) seems just the right thing to use for such data.

所以问题是:在PHP 5.5中使用什么来缓存少量数据而不是APC?

So the question is: what to use in php 5.5 to cache small bits of data instead of APC?

推荐答案

从PHP 5.5开始,APC用户数据存储分别打包为 PECL APCu .

Starting from PHP 5.5 the APC user data storage is packaged separately as PECL APCu.

  • Source code: http://pecl.php.net/package/APCu
  • MacOS homebrew package is php55-apcu (brew install php55-apcu)
  • Debian/ubuntu is called php5-apcu (apt-get install php5-apcu)
  • Fedora/RedHat is called php-pecl-apcu (yum install php-pecl-apcu)
  • Windows - use precompiled APCu dll - follow instructions provided in the answer below.

这使您可以使用所有用户缓存功能 ,例如 apc_store().它还将为extension_loaded('apc')返回true-这意味着所有依赖APC的库都将类似于PHP 5.4.

This allows you to use all user cache functions, such as apc_store(). It will also return true for extension_loaded('apc') - this means that all libraries depending on APC will work similarly to PHP 5.4.

这篇关于用什么代替php 5.5中的apc用户数据缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆