redis

2018-03-02  本文已影响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
上一篇 下一篇

猜你喜欢

热点阅读