From 67d57d8e1aaff7cc57cd030bdb3349337e7e9092 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Wed, 6 Aug 2025 16:47:19 +0800 Subject: Test whether REDIS Channel can cache not-consumed data --- Code/test_redis_publish.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Code') 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 -- cgit v1.2.1