summaryrefslogtreecommitdiff
path: root/session/memstore.go
blob: 97d70a1d8111ebe59b54f911ac903d068d28b8c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
}