I’ve seen this issue before, and it wasn’t caused by a Redis write failure or data loss. The real problem was that Redis had run out of memory.
You can check this using the INFO command.
Follow is the example code.
If used_memory_human and maxmemory_human show the same value, it means Redis has reached its memory limit and can’t store any additional data.
import redis
# Connect to Redis
r = redis.Redis(
host="your-redis-host",
port=port_num,
db=db_num
)
# Fetch memory usage
memory_info = r.info("memory")
usage = {
"used_memory_human": memory_info.get("used_memory_human"),
"maxmemory_human": memory_info.get("maxmemory_human")
}
print(usage)