Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-ci-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v9.4.0
rev: v9.7.0
hooks:
# Spell check changed files
- id: cspell
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
hooks:
- id: hadolint-docker
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v9.4.0
rev: v9.7.0
hooks:
# Spell check changed files
- id: cspell
Expand Down
4 changes: 2 additions & 2 deletions .project-settings.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GOLANGCI_LINT_VERSION=v2.10.1
BUF_VERSION=v1.65.0
BUF_VERSION=v1.66.0
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUF_VERSION is bumped here, but the CI workflows that source .project-settings.env only read GO_VERSION/GOLANGCI_LINT_VERSION and never consume BUF_VERSION. As a result, this setting currently doesn't affect tooling versions in CI. Either plumb BUF_VERSION into the relevant workflow/Make targets or drop it to avoid a misleading configuration knob.

Suggested change
BUF_VERSION=v1.66.0

Copilot uses AI. Check for mistakes.
GO_VERSION=1.26.0
GCI_PREFIX=github.com/hyp3rd/hypercache
PROTO_ENABLED=true
PROTO_ENABLED=false
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include .project-settings.env

GOLANGCI_LINT_VERSION ?= v2.10.1
BUF_VERSION ?= v1.65.0
BUF_VERSION ?= v1.66.0
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUF_VERSION is updated here, but it doesn't appear to be used anywhere to actually pin/install buf (the Makefile installs github.com/bufbuild/buf/cmd/buf@latest). This makes the version bump effectively a no-op and can mislead readers into thinking buf is locked to v1.66.0. Consider either wiring BUF_VERSION into the buf install/prepare target (so installs are reproducible) or removing the variable entirely if it's not intended to control anything.

Suggested change
BUF_VERSION ?= v1.66.0

Copilot uses AI. Check for mistakes.
GO_VERSION ?= 1.26.0
GCI_PREFIX ?= github.com/hyp3rd/hypercache
PROTO_ENABLED ?= true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
github.com/valyala/fasthttp v1.69.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.50.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
Expand Down
38 changes: 28 additions & 10 deletions hypercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ func (hyperCache *HyperCache[T]) startBackgroundJobs(ctx context.Context) {
jobsCtx, cancel := context.WithCancel(ctx)

hyperCache.bgCancel = cancel
// Ensure shutdown signaling always drives context cancellation, even when
// stop consumers race to read the stop channel.
go func(stop <-chan bool, done <-chan struct{}, cancel context.CancelFunc) {
select {
case <-stop:
cancel()
case <-done:
}
}(hyperCache.stop, jobsCtx.Done(), cancel)

hyperCache.startExpirationRoutine(jobsCtx)
hyperCache.startEvictionRoutine(jobsCtx)
Expand Down Expand Up @@ -415,6 +424,13 @@ func (hyperCache *HyperCache[T]) handleExpirationSelect(ctx context.Context, tic
case <-hyperCache.evictCh:
// manual eviction trigger
hyperCache.evictionLoop(ctx)
case <-ctx.Done():
if tick != nil {
tick.Stop()
}

return true

case <-hyperCache.stop:
if tick != nil {
tick.Stop()
Expand All @@ -439,6 +455,11 @@ func (hyperCache *HyperCache[T]) startEvictionRoutine(ctx context.Context) {
select {
case <-tick.C:
hyperCache.evictionLoop(ctx)
case <-ctx.Done():
tick.Stop()

return

case <-hyperCache.stop:
tick.Stop()

Expand Down Expand Up @@ -967,17 +988,16 @@ const (

// Stop function stops the expiration and eviction loops and closes the stop channel.
func (hyperCache *HyperCache[T]) Stop(ctx context.Context) error {
// Stop the expiration and eviction loops
wg := sync.WaitGroup{}

wg.Go(func() {
hyperCache.stop <- true
})

wg.Wait()
// Best-effort stop signal for listeners that still rely on stop channel.
select {
case hyperCache.stop <- true:
default:
}

if hyperCache.bgCancel != nil {
hyperCache.bgCancel()

hyperCache.bgCancel = nil
}

hyperCache.once = sync.Once{}
Expand All @@ -992,8 +1012,6 @@ func (hyperCache *HyperCache[T]) Stop(ctx context.Context) error {
// Handle error
return err
}

cancel()
}

return nil
Expand Down
Loading