Using Memcached with Magento
Magento can use Memcached both as a cache and as a session storage. We recommend you use a different Memcached bucket for each purpose.
To use Memcached as a cache and as a session storage for your Magento site, follow these steps:
- Make sure that your Magento server is installed with libmemcached and the PECL memcached extension.
- Log into Magento’s administration console and set default value of the Cookie Lifetime in the Magento Session Cookie Management to 31536000 in order to comply with following Memcached protocol specification about expiration times:
Some commands involve a client sending some kind of expiration time
(relative to an item or to an operation requested by the client) to
the server. In all such cases, the actual value sent may either be
Unix time (number of seconds since January 1, 1970, as a 32-bit
value), or a number of seconds starting from current time. In the
latter case, this number of seconds may not exceed 606024*30 (number
of seconds in 30 days); if the number sent by a client is larger than
that, the server will consider it to be real Unix time value rather
than an offset from current time.
- Edit your site’s XML file, typically located at
app/etc/local.xml, and add the following to the
<session_cache_limiter></session _cache_limiter> <session_save> <![CDATA[memcache]]> </session_save> <session_save_path> <![CDATA[tcp://hostname1:port1?persistent=1&weight=1&timeout=10&retry_interval=10]]> </session_save_path> <cache> <backend> memcached </backend> <slow_backend> database </slow_backend> <slow_backend_store_data> 0 </slow_backend_store_data> <memcached> <servers> <server> <host> <![CDATA[hostname2]]> </host> <port> <![CDATA[port2]]> </port> <persistent> <![CDATA]> </persistent> <weight> <![CDATA]> </weight> <timeout> <![CDATA]> </timeout> <retry_interval> <![CDATA]> </retry_interval> <status> <![CDATA]> </status> </server> </servers> <compression> <![CDATA]> </compression> <cache_dir> <![CDATA]> </cache_dir> <hashed_directory_level> <![CDATA]> </hashed_directory_level> <hashed_directory_umask> <![CDATA]> </hashed_directory_umask> <file_name_prefix> <![CDATA]> </file_name_prefix> </memcached> </cache>
To modify these settings so that your Memcached buckets are used:
hostname1with the hostname of your sessions bucket
port1with the port of your sessions bucket
hostname2with the hostname of your cache bucket
port2with the port of your cache bucket
Displaying Memcached Howto – merged.md.
Redis Enterprise enables running Memcached buckets in a highly available and auto-scalable manner, with predictable top performance.
Redis Enterprise Software lets you install an enterprise grade Memcached cluster in your environment of choice, whether an on-premises data-center or your preferred cloud platform. It gives you full control of your data and configuration – no clustering or sharding knowledge required!
Memcached Cloud is a fully managed cloud service for hosting and running Memcached datasets in a highly available and scalable manner, with predictable and stable top performance. It provides a storage engine for standard Memcached, as well as in-memory replication and instant auto-failover within the same data center or across data centers. The service completely frees developers from dealing with nodes, clusters, scaling, data persistence issues or failure recovery.
For more information on using Redis Labs’ products and services with Magento please see the Howto page.