From e293a40d6bb62e4fa8cc212fcc8bb4b3501da287 Mon Sep 17 00:00:00 2001 From: physcik Date: Fri, 17 Apr 2026 23:11:33 +0500 Subject: Sesstion token generation + storage --- backend/src/Redis/Connection.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'backend/src/Redis/Connection.zig') diff --git a/backend/src/Redis/Connection.zig b/backend/src/Redis/Connection.zig index 83adb2c..737d5cb 100644 --- a/backend/src/Redis/Connection.zig +++ b/backend/src/Redis/Connection.zig @@ -28,11 +28,15 @@ pub const Message = struct { }; pub fn WriteToTopic(topic: []const u8, message: Message) !void { - _ = redis.redisCommand(connection, "SET %s:%s %s EX %d", - topic.ptr, - message.Key.ptr, - message.Value.ptr, + const rep = redis.redisCommand(connection, "SET %b:%b %b EX %d", + topic.ptr, topic.len, + message.Key.ptr, message.Key.len, + message.Value.ptr, message.Value.len, message.SecondsToLive); + + if (rep != null) { + redis.freeReplyObject(rep); + } } pub fn ReadFromTopic(topic: []const u8, Key: []const u8) ?[]const u8 { @@ -42,6 +46,9 @@ pub fn ReadFromTopic(topic: []const u8, Key: []const u8) ?[]const u8 { if (raw == null) { return null; } + defer { + redis.freeReplyObject(raw); + } const resp: *redis.redisReply = @alignCast(@ptrCast(raw)); if (resp.type != redis.REDIS_REPLY_STRING) { return null; -- cgit v1.3