Skip to content
Open
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 .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: check (${{ matrix.go}})
strategy:
matrix:
go: [1.23, 1.24, 1.25]
go: [1.24, 1.25, 1.26]
continue-on-error: true
steps:
- uses: EarthBuild/actions-setup@main
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ linters:
- nonamedreturns
- testpackage
- varnamelen
- wsl # deprecated
exclusions:
generated: lax
presets:
Expand Down
6 changes: 4 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VERSION 0.8
ARG go_version=1.25.1
# renovate: datasource=docker depName=golang
ARG go_version=1.26.0
FROM golang:$go_version-alpine
WORKDIR /src

Expand All @@ -15,7 +16,8 @@ src:

# lint runs all linters for golang
lint:
ARG golangci_lint_version=2.4.0
# renovate: datasource=docker depName=golangci/golangci-lint
ARG golangci_lint_version=2.9.0
FROM golangci/golangci-lint:v$golangci_lint_version-alpine
WORKDIR /src
COPY .golangci.yml .
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module go.expect.digital/cache

go 1.24.0

toolchain go1.25.7
toolchain go1.26.0

require golang.org/x/sync v0.19.0
2 changes: 1 addition & 1 deletion internal/list/list.go β†’ internal/linked/list.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package list
package linked

// Element represents a list element.
type Element[V any] struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package list
package linked

import (
"testing"
Expand Down
12 changes: 6 additions & 6 deletions lru/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"go.expect.digital/cache/internal/list"
"go.expect.digital/cache/internal/linked"
)

const defaultSize = 1024
Expand All @@ -32,8 +32,8 @@ type Cache[K comparable, V any] struct {
ttl time.Duration
getter Getter[K, V]
onEvict OnEvict[V]
cache *list.List[listValue[K, V]]
lookup map[K]*list.Element[listValue[K, V]]
cache *linked.List[listValue[K, V]]
lookup map[K]*linked.Element[listValue[K, V]]
pending map[K][]chan getterResult[V]
mu sync.RWMutex
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func (c *Cache[K, V]) Set(ctx context.Context, key K, value V) error {
}

// evict removes the element from the cache.
func (c *Cache[K, V]) evict(ctx context.Context, el *list.Element[listValue[K, V]]) (err error) {
func (c *Cache[K, V]) evict(ctx context.Context, el *linked.Element[listValue[K, V]]) (err error) {
c.cache.Remove(el)
delete(c.lookup, el.Value.key)

Expand Down Expand Up @@ -346,8 +346,8 @@ func New[K comparable, V any](options ...Option[K, V]) *Cache[K, V] {
c.n = defaultSize
}

c.cache = list.New[listValue[K, V]]()
c.lookup = make(map[K]*list.Element[listValue[K, V]])
c.cache = linked.New[listValue[K, V]]()
c.lookup = make(map[K]*linked.Element[listValue[K, V]])
c.pending = make(map[K][]chan getterResult[V])

return c
Expand Down