redis
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| redis [2019/11/19 13:30] – rex8312 | redis [2024/04/16 02:23] (현재) – rex8312 | ||
|---|---|---|---|
| 줄 19: | 줄 19: | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ===== 예제 ===== | ||
| + | |||
| + | <code python> | ||
| + | import os | ||
| + | import shlex | ||
| + | import subprocess | ||
| + | import time | ||
| + | from pathlib import Path | ||
| + | from IPython import embed | ||
| + | |||
| + | import psutil | ||
| + | import redis | ||
| + | |||
| + | |||
| + | def start_redis(port=6379, | ||
| + | cmd = [ | ||
| + | f' | ||
| + | f' | ||
| + | f' | ||
| + | # f' | ||
| + | # f' | ||
| + | # f' | ||
| + | ] | ||
| + | cmd = ' ' | ||
| + | server = subprocess.Popen(shlex.split(cmd)) | ||
| + | return server | ||
| + | |||
| + | |||
| + | def kill_processes(): | ||
| + | parent = psutil.Process(os.getpid()) | ||
| + | for child in parent.children(recursive=True): | ||
| + | child.kill() | ||
| + | parent.kill() | ||
| + | |||
| + | |||
| + | if __name__ == ' | ||
| + | |||
| + | port = 6379 | ||
| + | password = ' | ||
| + | | ||
| + | server = start_redis(port, | ||
| + | c = redis.Redis(port=port, | ||
| + | c.set(1, 1) | ||
| + | print(c.get(1)) | ||
| + | c.save() | ||
| + | # c.bgsave() | ||
| + | server.terminate() | ||
| + | kill_processes() | ||
| + | |||
| + | </ | ||
| + | | ||
| + | ===== 튜토리얼 ===== | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | ===== 대안 ===== | ||
| + | |||
| + | * https:// | ||
| + | |||
| + | |||
| + | {{tag> | ||
redis.1574170238.txt.gz · 마지막으로 수정됨: (바깥 편집)