From 9b6c8da5a8b6dc993766434827853492d0fd0c96 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Fri, 3 Feb 2017 16:42:52 +0100 Subject: [PATCH] vibe.http.session: Allow to remove a field from a session --- http/vibe/http/session.d | 11 +++++++++++ redis/vibe/db/redis/sessionstore.d | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/http/vibe/http/session.d b/http/vibe/http/session.d index 44d8066e02..79dff18621 100644 --- a/http/vibe/http/session.d +++ b/http/vibe/http/session.d @@ -93,6 +93,9 @@ struct Session { m_store.set(m_id, key, serialize(value)); } + // Removes a field from a session + void remove(string key) @safe { m_store.remove(m_id, key); } + /** Enables foreach-iteration over all keys of the session. */ @@ -174,6 +177,9 @@ interface SessionStore { /// Determines if a certain session key is set. bool isKeySet(string id, string key); + /// Removes a key from a session + void remove(string id, string key); + /// Terminates the given session. void destroy(string id); @@ -254,6 +260,11 @@ final class MemorySessionStore : SessionStore { return (key in m_sessions[id]) !is null; } + void remove(string id, string key) + { + m_sessions[id].remove(key); + } + void destroy(string id) { m_sessions.remove(id); diff --git a/redis/vibe/db/redis/sessionstore.d b/redis/vibe/db/redis/sessionstore.d index adfbb40e1c..d813b48c3c 100644 --- a/redis/vibe/db/redis/sessionstore.d +++ b/redis/vibe/db/redis/sessionstore.d @@ -66,6 +66,11 @@ final class RedisSessionStore : SessionStore { return m_db.hexists(id, key); } + void remove(string id, string key) + { + m_db.hdel(id, key); + } + void destroy(string id) { m_db.del(id);