summaryrefslogtreecommitdiff
path: root/backend/src/Redis/Connection.zig
diff options
context:
space:
mode:
authorphyscik <mynameisgennadiy@vk.com>2026-04-17 23:11:33 +0500
committerphyscik <mynameisgennadiy@vk.com>2026-04-17 23:11:33 +0500
commite293a40d6bb62e4fa8cc212fcc8bb4b3501da287 (patch)
treef0da17a7292dbfd8aa5722f9cbd774f9ad2f9e23 /backend/src/Redis/Connection.zig
parentc03658c1b5a8dad87f4b11d1b48f2c057ac3a439 (diff)
Sesstion token generation + storage
Diffstat (limited to 'backend/src/Redis/Connection.zig')
-rw-r--r--backend/src/Redis/Connection.zig15
1 files changed, 11 insertions, 4 deletions
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;