GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(rate): capture clock.Now() before acquiring lock in Increment · majorcontext/keep@4630ffa

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • internal/rate
    • counter.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎internal/rate/counter.go‎

Copy file name to clipboardExpand all lines: internal/rate/counter.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (s *Store) OnKeyDropped(fn func(key string)) {
6464
// If the store has reached maxKeys and the key is new, the increment is skipped.
6565
// If a key has reached maxTimestampsPerKey, the oldest entries are trimmed.
6666
func (s *Store) Increment(key string) {
67+
now := s.clock.Now()
6768
s.mu.Lock()
6869

6970
// Enforce key limit: skip new keys when at capacity.
@@ -78,7 +79,7 @@ func (s *Store) Increment(key string) {
7879
}
7980
}
8081

81-
s.data[key] = append(s.data[key], s.clock.Now())
82+
s.data[key] = append(s.data[key], now)
8283

8384
// Enforce per-key timestamp limit: trim oldest entries.
8485
if len(s.data[key]) > maxTimestampsPerKey {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.