Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
da440dil committed Aug 9, 2019
1 parent c4318e9 commit 8ba152f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![GoDoc](https://godoc.org/github.com/da440dil/go-counter?status.svg)](https://godoc.org/github.com/da440dil/go-counter)
[![Go Report Card](https://goreportcard.com/badge/github.com/da440dil/go-counter)](https://goreportcard.com/report/github.com/da440dil/go-counter)

Distributed rate limiting with pluggable storage to store a counters state.
Distributed rate limiting with pluggable storage for storing a counters state.

## Basic usage

Expand All @@ -21,7 +21,7 @@ if v, err := c.Count("key"); err != nil {
}
} else {
// Counter value equals 1
// Remainder (v) equals 0
// Remainder value (v) equals 0
// Next c.Count("key") call will return TTLError
}
```
Expand Down
7 changes: 2 additions & 5 deletions gateway/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"
)

// Gateway is a gateway to memory storage.
// Gateway to memory storage.
type Gateway struct {
*storage
}
Expand All @@ -18,10 +18,7 @@ func New(cleanupInterval time.Duration) *Gateway {
items: make(map[string]*item),
cleaner: newCleaner(cleanupInterval),
}
// This trick ensures that cleanup goroutine does not keep
// the returned Gateway from being garbage collected.
// When it is garbage collected, the finalizer stops cleanup goroutine,
// after which storage can be collected.
// See https://gist.github.com/da440dil/6469a37e649a560f528fd116fa2e874d
gw := &Gateway{s}
go s.cleaner.Run(s.deleteExpired)
runtime.SetFinalizer(gw, finalizer)
Expand Down
2 changes: 1 addition & 1 deletion gateway/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var incr = redis.NewScript(
"return {v, t}",
)

// Gateway is a gateway to Redis storage.
// Gateway to Redis storage.
type Gateway struct {
client *redis.Client
}
Expand Down

0 comments on commit 8ba152f

Please sign in to comment.