ex-support
All checks were successful
Deploy on push / deploy (push) Successful in 1m59s

This commit is contained in:
Untone 2024-09-27 10:18:08 +03:00
parent e2b54b37dd
commit 31867d3c6c

View File

@ -57,8 +57,17 @@ class RedisService:
return
await self._client.publish(channel, data)
async def set(self, key, data):
await self.execute("set", key, data)
async def set(self, key, data, ex=None):
# Prepare the command arguments
args = [key, data]
# If an expiration time is provided, add it to the arguments
if ex is not None:
args.append("EX")
args.append(ex)
# Execute the command with the provided arguments
await self.execute("set", *args)
async def get(self, key):
return await self.execute("get", key)