added redis py code

This commit is contained in:
2025-10-09 13:10:37 +03:30
parent 34d19fe29e
commit 8565b4051e

View File

@@ -0,0 +1,22 @@
import redis
method=int(input("Enter Method: (1.Read/2.Write): "))
r = redis.Redis(host="ip", port=6379,db=0)
if (method == 1):
key=str(input("enter key name: "))
value=r.get(key)
if value == None:
print("Undefined Key")
exit
else:
print(value.decode('utf-8'))
elif (method == 2):
key=str(input("enter key name: "))
value=str(input("enter value: "))
r.set(key,value)
else:
print("Incorrect Input")
exit