diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index de2232c..7381a65 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -45,14 +45,6 @@ you must be able to justify that. #### Stylistic guide (mandatory) - [ ] My code complies with the [styles guide](https://github.com/uber-go/guide/blob/master/style.md). -- [ ] My commit history is clean (only contains changes relating to my - issue/pull request and no reverted-my-earlier-commit changes) and commit - messages start with identifiers of related issues in square brackets. - - **Example:** `[#42] Short commit description` - - If necessary both of these can be achieved even after the commits have been - made/pushed using [rebase and squash](https://git-scm.com/docs/git-rebase). #### Before merging (mandatory) - [ ] Check __target__ branch of PR is set correctly diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d5962e..bf71bcf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,5 +24,5 @@ jobs: - name: lint uses: golangci/golangci-lint-action@v6 with: - version: latest + version: v1.61.0 args: --timeout=4m -v --out-${NO_FUTURE}format colored-line-number diff --git a/.golangci.yml b/.golangci.yml index 7fa82a2..ed7938b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: build-tags: - integration modules-download-mode: readonly - go: '1.17' + go: '1.19' output: formats: - format: tab diff --git a/cache_test.go b/cache_test.go index e572b50..5d3e347 100644 --- a/cache_test.go +++ b/cache_test.go @@ -676,6 +676,12 @@ func TestCache_Ratio(t *testing.T) { t.Logf("actual size: %d, capacity: %d", c.Size(), capacity) t.Logf("actual: %.2f, optimal: %.2f", statsCounter.Snapshot().HitRatio(), o.Ratio()) + time.Sleep(2 * time.Second) + + if size := c.Size(); size != capacity { + t.Fatalf("not valid cache size. expected %d, but got %d", capacity, size) + } + mutex.Lock() defer mutex.Unlock() t.Logf("evicted: %d", m[CauseOverflow]) diff --git a/scripts/deps.sh b/scripts/deps.sh index 6579014..3e49b7b 100644 --- a/scripts/deps.sh +++ b/scripts/deps.sh @@ -7,4 +7,3 @@ bash -s -- -b "$(go env GOPATH)"/bin v1.61.0 go install github.com/daixiang0/gci@latest GO111MODULE=on go install mvdan.cc/gofumpt@latest -go install github.com/golang/mock/mockgen@latest diff --git a/stats/counter.go b/stats/counter.go index de2fa87..82f3357 100644 --- a/stats/counter.go +++ b/stats/counter.go @@ -27,7 +27,7 @@ type Counter struct { misses *xsync.Adder evictions *xsync.Adder evictionWeight *xsync.Adder - rejectedSets *xsync.Adder + rejections *xsync.Adder loadSuccesses *xsync.Adder loadFailures *xsync.Adder totalLoadTime *xsync.Adder @@ -40,7 +40,7 @@ func NewCounter() *Counter { misses: xsync.NewAdder(), evictions: xsync.NewAdder(), evictionWeight: xsync.NewAdder(), - rejectedSets: xsync.NewAdder(), + rejections: xsync.NewAdder(), loadSuccesses: xsync.NewAdder(), loadFailures: xsync.NewAdder(), totalLoadTime: xsync.NewAdder(), @@ -62,7 +62,7 @@ func (c *Counter) Snapshot() Stats { misses: c.misses.Value(), evictions: c.evictions.Value(), evictionWeight: c.evictionWeight.Value(), - rejections: c.rejectedSets.Value(), + rejections: c.rejections.Value(), loadSuccesses: c.loadSuccesses.Value(), loadFailures: c.loadFailures.Value(), //nolint:gosec // overflow is handled above @@ -93,7 +93,7 @@ func (c *Counter) RecordEviction(weight uint32) { // RecordRejections records rejections of entries. Cache rejects entries only if they have too much weight. func (c *Counter) RecordRejections(count int) { //nolint:gosec // there is no overflow - c.rejectedSets.Add(uint64(count)) + c.rejections.Add(uint64(count)) } // RecordLoadSuccess records the successful load of a new entry. This method should be called when a cache request