add using atomic
Some checks failed
lint / lint (pull_request) Has been cancelled
pr / test (pull_request) Has been cancelled

This commit is contained in:
2024-11-25 11:20:17 +03:00
parent 775429d4d6
commit 42f890c418
2 changed files with 12 additions and 19 deletions

View File

@@ -4,7 +4,7 @@ import (
"context"
"sort"
"strings"
"sync"
"sync/atomic"
"time"
cache "github.com/patrickmn/go-cache"
@@ -40,8 +40,7 @@ type memoryStore struct {
funcDelete store.FuncDelete
store *cache.Cache
opts store.Options
isConnected bool
mutex sync.Mutex
isConnected atomic.Int32
}
func (m *memoryStore) key(prefix, key string) string {
@@ -277,8 +276,6 @@ func (m *memoryStore) fnList(ctx context.Context, opts ...store.ListOption) ([]s
}
func (m *memoryStore) connect(ctx context.Context) error {
m.mutex.Lock()
defer m.mutex.Unlock()
m.isConnected = true
m.isConnected.CompareAndSwap(0, 1)
return nil
}