We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a742f0 commit 351bc32Copy full SHA for 351bc32
memorystore/store.go
@@ -261,7 +261,7 @@ type bucket struct {
261
lastTick uint64
262
263
// lock guards the mutable fields.
264
- lock sync.Mutex
+ lock sync.RWMutex
265
}
266
267
// newBucket creates a new bucket from the given tokens and interval.
@@ -277,8 +277,8 @@ func newBucket(tokens uint64, interval time.Duration) *bucket {
277
278
// get returns information about the bucket.
279
func (b *bucket) get() (tokens uint64, remaining uint64, retErr error) {
280
- b.lock.Lock()
281
- defer b.lock.Unlock()
+ b.lock.RLock()
+ defer b.lock.RUnlock()
282
283
tokens = b.maxTokens
284
remaining = b.availableTokens
0 commit comments