可視化工具:RedisDesktopManagerhtml
redis載地址:https://github.com/MSOpenTech/redis/releases。python
redis-server.exe redis.windows.conf
redis-cli.exe -h 127.0.0.1 -p 6379
redis-cli # 啓動客戶端 set key value # 設置值 get key # 取出值
字符串、字典、列表、集合、有序集合git
https://www.runoob.com/redis/redis-tutorial.htmlgithub
可持久化、單線程單進程併發redis
pip3 install redis
import redis r = redis.Redis(host='127.0.0.1', port=6379)
import redis pool = redis.ConnectionPool(host='127.0.0.1', port=6379) r = redis.Redis(connection_pool=pool)
import redis r = redis.Redis(db=0) #第幾個庫總共有15個庫
# 1.將緩存存儲位置配置到redis中:settings.py #首先要安裝依賴pip install django-redis。 CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "CONNECTION_POOL_KWARGS": {"max_connections": 100} } } } # 2.操做cache模塊直接操做緩存:views.py from django.core.cache import cache # 結合配置文件實現插拔式 # 存放token,能夠直接設置過時時間 cache.set('token', 'header.payload.signature', 10) # 取出token token = cache.get('token')