Skip to content

Commit 6d541cb

Browse files
committed
fix: use normal mutex for cache
1 parent 1ebba7f commit 6d541cb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/memorystore/providers/inmemory/stores/session_store.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type SessionEntry struct {
2424
// SessionStore struct to store the env variables
2525
type SessionStore struct {
2626
wg sync.WaitGroup
27-
mutex sync.RWMutex
27+
mutex sync.Mutex
2828
store map[string]*SessionEntry
2929
// stores expireTime: key to remove data when cache is full
3030
// map is sorted by key so older most entry can be deleted first
@@ -35,7 +35,7 @@ type SessionStore struct {
3535
// NewSessionStore create a new session store
3636
func NewSessionStore() *SessionStore {
3737
store := &SessionStore{
38-
mutex: sync.RWMutex{},
38+
mutex: sync.Mutex{},
3939
store: make(map[string]*SessionEntry),
4040
keyIndex: make(map[int64]string),
4141
stop: make(chan struct{}),
@@ -71,8 +71,8 @@ func (s *SessionStore) clean() {
7171

7272
// Get returns the value of the key in state store
7373
func (s *SessionStore) Get(key, subKey string) string {
74-
s.mutex.RLock()
75-
defer s.mutex.RUnlock()
74+
s.mutex.Lock()
75+
defer s.mutex.Unlock()
7676
currentTime := time.Now().Unix()
7777
k := fmt.Sprintf("%s:%s", key, subKey)
7878
if v, ok := s.store[k]; ok {

0 commit comments

Comments
 (0)