Skip to content

Commit 351bc32

Browse files
authored
Switch to rlock (#50)
1 parent 1a742f0 commit 351bc32

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

memorystore/store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ type bucket struct {
261261
lastTick uint64
262262

263263
// lock guards the mutable fields.
264-
lock sync.Mutex
264+
lock sync.RWMutex
265265
}
266266

267267
// newBucket creates a new bucket from the given tokens and interval.
@@ -277,8 +277,8 @@ func newBucket(tokens uint64, interval time.Duration) *bucket {
277277

278278
// get returns information about the bucket.
279279
func (b *bucket) get() (tokens uint64, remaining uint64, retErr error) {
280-
b.lock.Lock()
281-
defer b.lock.Unlock()
280+
b.lock.RLock()
281+
defer b.lock.RUnlock()
282282

283283
tokens = b.maxTokens
284284
remaining = b.availableTokens

0 commit comments

Comments
 (0)