Skip to content

Redis

官方文档地址:https://redis.io/docs/

python 库

https://github.com/redis/redis-py

python
import redis

redis.Redis(
    host='127.0.0.1',
    port=6379,
    username='root',
    password='123456',
    db=0,
    decode_responses=True
)

docker-compose 启动 redis

yaml
version: "3"

services:
  redis:
    image: redis
    container_name: redis
    restart: always
    command: redis-server --requirepass 123456
    volumes:
      - "/data/redis/data:/data"
    ports:
      - "127.0.0.1:6379:6379"