summaryrefslogtreecommitdiff
path: root/session/memstore.go
diff options
context:
space:
mode:
authorAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-28 19:32:33 +0300
committerAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-28 19:32:33 +0300
commit18a9096684ab0b1468a08d442d38b7b675d94810 (patch)
tree16e335e56ac0bf7986c3fbcd924f2ac0e00106f8 /session/memstore.go
parent25160ef84704c0f4ef6e8c6cf2e282e216701139 (diff)
Session middlewareHEADmaster
Diffstat (limited to 'session/memstore.go')
-rw-r--r--session/memstore.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/session/memstore.go b/session/memstore.go
new file mode 100644
index 0000000..97d70a1
--- /dev/null
+++ b/session/memstore.go
@@ -0,0 +1,25 @@
+package session
+
+import (
+ "context"
+ "sync"
+)
+
+type MemoryStore struct {
+ store sync.Map
+}
+
+func (s *MemoryStore) Load(ctx context.Context, sessionID string) Value {
+ val, ok := s.store.Load(sessionID)
+ if ok {
+ return val.(Value)
+ }
+
+ return Value{}
+}
+
+func (s *MemoryStore) Save(ctx context.Context, sessionID string, value Value) error {
+ s.store.Store(sessionID, value)
+
+ return nil
+}