From a2155976f39cece96f540ab9677bb053663f5134 Mon Sep 17 00:00:00 2001 From: qmqz Date: Fri, 28 Feb 2025 18:36:49 +0800 Subject: [PATCH] fix --- lib/base/redis/redis.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/base/redis/redis.dart b/lib/base/redis/redis.dart index 3fb2b57..689e5b3 100644 --- a/lib/base/redis/redis.dart +++ b/lib/base/redis/redis.dart @@ -28,13 +28,20 @@ class Redis { Future get(String key) async { return await _command?.send_object(["GET", key]); } + + Future setWithExpiry(String key, String value, int ttlInSeconds) async { + var response = await _command + ?.send_object(["SETEX", key, ttlInSeconds.toString(), value]); + return response == "OK"; + } } class RedisConfig { String host; int port; - RedisConfig( - {required this.host, - this.port = 6379,}); + RedisConfig({ + required this.host, + this.port = 6379, + }); }