redis

作者: 马小跳_ | 来源:发表于2018-03-02 08:27 被阅读5次

安装

wget http://download.redis.io/releases/redis-4.0.2.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable
make


安装包
yum install redis

rpm安装

情况:
    1.直接给rpm包
    2.yum install redis
        安装公司自定制的yum源
        安装官方

启动

/etc/init.d/redis start

src/redis-server redis.conf

找到服务并杀掉
ps -e|grep redis
kill -9 11111

python操作redis

pip install redis

pool = redis.ConnectionPool(host="47.93.4.198", port=6379)
conn = redis.Redis(connection_pool=pool)

conn = redis.Redis(host="47.93.4.198", port=6379)

通过单例实现共享连接池

django-redis组件

pip install django-redis

配置文件:

CACHES = {
  "default": {
    "BACKEND": "django_redis.cache.RedisCache",
    "LOCATION": "redis://47.93.4.198:6379",
    "OPTIONS": {
    "CLIENT_CLASS": "django_redis.client.DefaultClient",
    #"PASSWORD": "asdfasdf",
    }
  }
}

使用:
import django_redis
conn = django_redis.get_redis_connection()

连接虚拟机

systemctl stop firewalld
systemctl disable firewalld


redis.conf
    bind 0.0.0.0
    protected_mode no

相关文章

网友评论

      本文标题:redis

      本文链接:https://www.haomeiwen.com/subject/xmuoxftx.html