This commit is contained in:
2025-02-28 18:36:49 +08:00
parent 79cba2ea7a
commit a2155976f3

View File

@@ -28,13 +28,20 @@ class Redis {
Future<String?> get(String key) async { Future<String?> get(String key) async {
return await _command?.send_object(["GET", key]); return await _command?.send_object(["GET", key]);
} }
Future<bool> setWithExpiry(String key, String value, int ttlInSeconds) async {
var response = await _command
?.send_object(["SETEX", key, ttlInSeconds.toString(), value]);
return response == "OK";
}
} }
class RedisConfig { class RedisConfig {
String host; String host;
int port; int port;
RedisConfig( RedisConfig({
{required this.host, required this.host,
this.port = 6379,}); this.port = 6379,
});
} }