summaryrefslogtreecommitdiff
path: root/session/memstore.go
diff options
context:
space:
mode:
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
+}