Skip to content

Commit

Permalink
vibe.http.session: Allow to remove a field from a session
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Feb 3, 2017
1 parent 5ccc30c commit 9b6c8da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions http/vibe/http/session.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions redis/vibe/db/redis/sessionstore.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9b6c8da

Please sign in to comment.