-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default cache backend #124
Comments
Excellent extension! It would be fantastic to have this included. |
Hello. We are actively researching solutions for that and definitely Redis is under consideration. |
Although I think Redis makes an excellent backend for just about any size deployment I wasn't suggesting Redis as the default since it obviously adds a Redis server as a dependency. I was only suggesting that my file-based backend be bundled and used as the default since it doesn't degrade over time and is more efficient to boot. |
Hello Collin, thanks for the suggestion. It definitely makes sense and I will put in the backlog. As for the license we can take MIT, Apache, BSD. |
Oh, looks like I already had it licensed under BSD after-all.. |
An optional Redis cache would be fantastic! But I agree with Colin, a file based one is necessary for people that doesn't have access to dedicated servers |
There's a Drupal cache module called Boost that generates html pages accesible via special htaccess rules (generated by the module itself), so the content is being served directly by the web server bypassing php/database. It's just another idea for a cache system. |
Also brilliant, from the same developer, is the more abstract Expire module, which tracks the association of items within collections, so that a change to that item prompts cache invalidation in every page where it appears. |
Hello. File backend (based on Colin's code) will become default once we merge a set of important changes from 1.x series. Redis backend will be default for multi-server installations replacing two-level memcache + DB setup. This merge is expected to happen after Q1 '13. |
@mage2-team what's about redis? |
@igor-svizev lib/Cm/Cache/Backend/Redis.php? |
@kandy could you describe for me, what I should change to start use it? |
I don't try do it by self |
@kandy thanks, <?xml version="1.0"?>
<config>
...
<cache>
<frontend name="default">
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options><server>127.0.0.1</server> <!-- or absolute path to unix socket -->
<port>6379</port>
<persistent></persistent> <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
<database>0</database> <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
<password></password> <!-- Specify if your Redis server requires authentication -->
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to random connection failures; a value of 1 will not retry after the first failure -->
<read_timeout>10</read_timeout> <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
<automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
<compress_data>1</compress_data> <!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_tags>1</compress_tags> <!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_threshold>20480</compress_threshold> <!-- Strings below this size will not be compressed -->
<compression_lib>lzf</compression_lib> <!-- Supports gzip, lzf, lz4 (as l4z) and snappy -->
<use_lua>0</use_lua> <!-- Set to 1 if Lua scripts should be used for some operations -->
</backend_options>
</frontend>
<frontend name="page_cache">
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server> <!-- or absolute path to unix socket -->
<port>6379</port>
<persistent></persistent> <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
<database>1</database> <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
<password></password> <!-- Specify if your Redis server requires authentication -->
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to random connection failures -->
<lifetimelimit>57600</lifetimelimit> <!-- 16 hours of lifetime for cache record -->
<compress_data>0</compress_data> <!-- DISABLE compression for EE FPC since it already uses compression -->
</backend_options>
</frontend>
</cache>
...
</config> PS: In that folder we also have Cm_Cache_Backend_File, what's different between this class & standard Magento cache in files? |
Of course advanced users can do some research and choose a backend that best suits their needs, but the default backend (Zend_Cache_Backend_File) is widely used simply because it is the default despite it having terrible performance with cleaning tags. For example there are several forum threads where users recommend shop owners to clear their cache periodically to maintain good performance. Clearing cache should not be necessary to maintain good performance for a small store. Also, if there is a better solution with no drawbacks, why not use it?
I recommend changing the default to Cm_Cache_Backend_File which has the same basic requirements (write access to var/cache) but does not rape the file system when clearing cache entries by tag. It does perform one append-only write for each tag when a cache item is saved, but overall utilizes the disk much more conservatively (way fewer inodes, way fewer file reads). I'm not sure what your requirements are for bundling third-party code, but here it is if interested: https://github.com/colinmollenhour/Cm_Cache_Backend_File
I will add a license to it if you like, let me know if you have a preference.
Summary from my Imagine 2012 presentation:
The text was updated successfully, but these errors were encountered: