Skip to content

Commit

Permalink
Use the renamed ringlist package
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnsk committed Oct 16, 2023
1 parent 763d3d3 commit b8db083
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/mgnsk/evcache/v3
go 1.19

require (
github.com/mgnsk/list v0.0.0-20230905211842-36eaa80d0e17
github.com/onsi/gomega v1.27.10
github.com/mgnsk/ringlist v0.0.0-20231016175938-072bd9da3594
github.com/onsi/gomega v1.28.0
)

require (
Expand Down
10 changes: 5 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mgnsk/list v0.0.0-20230905211842-36eaa80d0e17 h1:wbj6xVmYBWNsWGSIa83XBA2zTooHaBcECk5DSAsS3Vo=
github.com/mgnsk/list v0.0.0-20230905211842-36eaa80d0e17/go.mod h1:NSeUCVwmqTJGeKJW1DFe0En63T065/tLyj5HPwwBZd0=
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/mgnsk/ringlist v0.0.0-20231016175938-072bd9da3594 h1:jUaUheJ+LrYgnsp2oBz1wIJcIJk8aQtZLWIHbSlq754=
github.com/mgnsk/ringlist v0.0.0-20231016175938-072bd9da3594/go.mod h1:bVpxwIf/UWlX72d9usjtuZoNRgFLdTL7iABnOpEZubk=
github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI=
github.com/onsi/gomega v1.28.0 h1:i2rg/p9n/UqIDAMFUJ6qIUUMcsqOuUHgbpbu235Vr1c=
github.com/onsi/gomega v1.28.0/go.mod h1:A1H2JE76sI14WIP57LMKj7FVfCHx3g3BcZVjJG8bjX8=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
Expand Down
8 changes: 4 additions & 4 deletions internal/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync/atomic"
"time"

"github.com/mgnsk/list"
"github.com/mgnsk/ringlist"
)

// If cap is 0, map hits this size and then shrinks by half, it is reallocated.
Expand All @@ -31,7 +31,7 @@ func (r *record[V]) Wait() {
}

// Element is the cache element.
type Element[V any] *list.Element[record[V]]
type Element[V any] *ringlist.Element[record[V]]

// RecordMap is the cache's element map.
type RecordMap[K comparable, V any] map[K]Element[V]
Expand All @@ -41,7 +41,7 @@ type Backend[K comparable, V any] struct {
timer *time.Timer
done chan struct{}
xmap RecordMap[K, V]
list list.List[record[V]]
list ringlist.List[record[V]]
pool sync.Pool
earliestExpireAt int64
cap int
Expand Down Expand Up @@ -82,7 +82,7 @@ func (b *Backend[K, V]) Len() int {
func (b *Backend[K, V]) Reserve() Element[V] {
elem, ok := b.pool.Get().(Element[V])
if !ok {
elem = list.NewElement(record[V]{value: *new(V)})
elem = ringlist.NewElement(record[V]{value: *new(V)})
}

elem.Value.wg.Add(1)
Expand Down

0 comments on commit b8db083

Please sign in to comment.