diff --git a/services/redis.py b/services/redis.py index 8cd3367c..5db49c7a 100644 --- a/services/redis.py +++ b/services/redis.py @@ -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)