mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
39 lines
No EOL
1 KiB
Python
39 lines
No EOL
1 KiB
Python
import redis
|
|
|
|
# Redis connection configuration
|
|
redis_client = redis.Redis(
|
|
host='maglev.proxy.rlwy.net',
|
|
port=16780,
|
|
password='beVfOKcZjMUCBiZIQnvSMivhpSeijpKP',
|
|
username='default',
|
|
db=0,
|
|
decode_responses=True
|
|
)
|
|
|
|
try:
|
|
print("Connecting to Redis...")
|
|
# Test connection
|
|
redis_client.ping()
|
|
print("Successfully connected to Redis!")
|
|
|
|
# Get all keys to see what's cached
|
|
keys = redis_client.keys('*')
|
|
print(f"Found {len(keys)} keys in Redis:")
|
|
for key in keys[:10]: # Show first 10 keys
|
|
print(f" - {key}")
|
|
|
|
if len(keys) > 10:
|
|
print(f" ... and {len(keys) - 10} more keys")
|
|
|
|
# Clear all data in current database
|
|
result = redis_client.flushdb()
|
|
print(f"Redis cache cleared: {result}")
|
|
|
|
# Verify it's cleared
|
|
keys_after = redis_client.keys('*')
|
|
print(f"Keys remaining after clear: {len(keys_after)}")
|
|
|
|
except redis.exceptions.ConnectionError as e:
|
|
print(f"Failed to connect to Redis: {e}")
|
|
except Exception as e:
|
|
print(f"Error: {e}") |