From 31c7177008e901215f8f0b37dea96573b82222da Mon Sep 17 00:00:00 2001 From: idc77 <87644834+idc77@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:55:40 +0100 Subject: [PATCH] added session.UnSet() function --- session.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/session.go b/session.go index 879a724..403c190 100644 --- a/session.go +++ b/session.go @@ -223,6 +223,17 @@ func (s *Session) MustGet(key string) interface{} { panic("Key \"" + key + "\" does not exist") } +// UnSet will delete the key and has no return value +func (s *Session) UnSet(key string) { + s.rwmutex.Lock() + defer s.rwmutex.Unlock() + if s.Keys != nil { + if _, exists := s.Keys[key]; exists { + delete(s.Keys, key) + } + } +} + // IsClosed returns the status of the connection. func (s *Session) IsClosed() bool { return s.closed()