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, + }); }