Connecting Magento with Redis by UNIX socket

本文介绍如何通过配置Magento使用Redis进行缓存优化,并利用UNIX socket替代TCP/IP连接以提高效率。此外,还提供了Redis会话及后端配置的相关资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://www.yireo.com/tutorials/magento/magento-performance/1640-connecting-magento-with-redis-by-unix-socket

1. 在MAGENTO里面如何使用 REDIS

http://devdocs.magento.com/guides/m1x/ce18-ee113/using_redis.html


2. 使用unit socket 代替 自带的tcp连接方式

The main method of optimizing Magento is through caching, and the more efficient caching is handled, the faster Magento becomes. Using Redis as caching backend is a popular way of handling caching entries as efficiently as possible. This guide covers how to configure Magento for Redis using sockets, instead of a TCP/IP port.


Reconfiguring Redis to listen to a UNIX socket

To use a UNIX socket instead, open up the file /etc/redis.conf and locate the line mentioning unixsocket. Replace it with the following:

unixsocket /var/tmp/redis.sock
unixsocketperm 777

The location of the socket-file /var/tmp/redis.sock is a rather personal choice - it could be another location as well, but make sure it is not /tmp which would be insecure. Also note the permissions are set to 777 - this means that any user is able to read and write to the socket. We assumed this is not really bad because we' re dealing with a webserver anyway. If you wish to modify this to a more secure mode, make sure that the UNIX user that runs the webservice processes is able to read and write to the socket.

After modifying the Redis file, restart Redis itself:

service redis restart

If all goes well, Redis should be listening now to both through TCP/IP as through socket.


<cache>
    <backend>Cm_Cache_Backend_Redis</backend>
    <backend_options>
        <server>/var/tmp/redis.sock</server>
        <port>0</port>
        <database>0</database>
        <password></password>
        <force_standalone>0</force_standalone>
        <connect_retries>1</connect_retries>
        <automatic_cleaning_factor>0</automatic_cleaning_factor>
        <compress_data>1</compress_data>
        <compress_tags>1</compress_tags>
        <compress_threshold>20480</compress_threshold>
        <compression_lib>gzip</compression_lib>
        <persistent>0</persistent>
    </backend_options>
</cache>

3. Redis session config

https://github.com/colinmollenhour/Cm_RedisSession/blob/master/README.md


4. Redis backend config

https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/blob/master/README.md

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值