基于Redis的邮件异步发送工具

jianfly.com 2019-01-31 2519次浏览

安装redis

redis.io官网下载并解压

make PREFIX=/usr/local/redis intall

mkdir -p usr/local/redis/etc/

将redis.config复制到/usr/local/redis/etc/redis.conf

启动脚本utils/redis_init_script修改

image

做软链

mkdir /etc/redis

ln -s /usr/local/redis/etc/redis.conf /etc/redis/6379.conf

复制启动脚本

cp redis_init_script /etc/init.d/redis

启动

/etc/init.d/redis start

后台运行

image

自动启动

image

chkconfig –add redis

chkconfig redis on

之后的启动和停止命令

service redis start

service redis stop

下载phpredis拓展,解压,进入phpredis

命令:phpize

./configure –with-php-config=/usr/local/php/bin/php-config

make && make install

vim /usr/local/php/etc/php.ini

image

github上下载yiisoft/yii2-redis

php composer.phar require –prefer-dist yiisoft/yii2-redis

web.php中增加配置

image

Yii::$app->redis->set(“phpredis”, “100”); //赋值

var_dump(Yii::$app->redis->keys(“*”)); //打印所有

echo Yii::$app->redis->get(“phpredis”); //获取值