diff options
author | Alexander NeonXP Kiryukhin <i@neonxp.ru> | 2024-07-28 19:32:33 +0300 |
---|---|---|
committer | Alexander NeonXP Kiryukhin <i@neonxp.ru> | 2024-07-28 19:32:33 +0300 |
commit | 18a9096684ab0b1468a08d442d38b7b675d94810 (patch) | |
tree | 16e335e56ac0bf7986c3fbcd924f2ac0e00106f8 /session/memstore.go | |
parent | 25160ef84704c0f4ef6e8c6cf2e282e216701139 (diff) |
Diffstat (limited to 'session/memstore.go')
-rw-r--r-- | session/memstore.go | 25 |
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 +} |