Jul 17, 2024
import os
import redis
host = os.environ['HOST']
port = os.environ['PORT']
password = os.environ['PASSWORD']
if not host or not port:
return {'statusCode': 500, 'body': 'Missing required parameters'}
client = redis.StrictRedis(host=host, port=port, password=password, decode_responses=True)
client.set('CloudTech', 'Elastic Cache Demo from Lambda Python')
value = client.get('CloudTech')
return {'statusCode': 200, 'body': f'Value from cache: {value}'}
redis-cli set key valueredis-cli get keyredis-cli keys *