diff options
author | Hui Lan <lanhui@zjnu.edu.cn> | 2025-08-06 16:47:19 +0800 |
---|---|---|
committer | Hui Lan <lanhui@zjnu.edu.cn> | 2025-08-06 16:47:19 +0800 |
commit | 67d57d8e1aaff7cc57cd030bdb3349337e7e9092 (patch) | |
tree | 0703c9b99df7a28ebf7ef78e57a960ffd4b56089 | |
parent | c556c692c613a9d306bc4019e5cf07b3ac89e054 (diff) |
Test whether REDIS Channel can cache not-consumed data
-rw-r--r-- | Code/test_redis_publish.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Code/test_redis_publish.py b/Code/test_redis_publish.py index b33ceed..937833f 100644 --- a/Code/test_redis_publish.py +++ b/Code/test_redis_publish.py @@ -1,13 +1,14 @@ import os, redis, json, time from configure import REDIS_CHANNEL -def publish(): +def publish(number): redis_host = os.getenv('REDIS_HOST', '127.0.0.1') redis_password = os.getenv('REDIS_PASSWORD', '123456') r = redis.Redis(host=redis_host, port=6379, password=redis_password, db=0) - r.publish(REDIS_CHANNEL, json.dumps({'filename':'a.txt', 'data':'123'})) + r.publish(REDIS_CHANNEL, json.dumps({'filename':'a.txt', 'data':str(number)})) +n = 0 while True: - publish() + publish(n) time.sleep(3) - + n += 1 |