Skip to content

Commit 0426d61

Browse files
committed
将 NewLoader 改成私有的
1 parent 5a62ec8 commit 0426d61

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

lfu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newLFUCache(conf *config) Cache {
4040
config: conf,
4141
itemMap: make(map[string]*heap.Item, mapInitialCap),
4242
itemHeap: heap.New(sliceInitialCap),
43-
loader: NewLoader(conf.singleflight),
43+
loader: newLoader(conf.singleflight),
4444
}
4545

4646
return cache

load.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ type loader struct {
2626
group *flight.Group
2727
}
2828

29-
// NewLoader creates a loader.
29+
// newLoader creates a loader.
3030
// It also creates a singleflight group to call load if singleflight is true.
31-
func NewLoader(singleflight bool) *loader {
31+
func newLoader(singleflight bool) *loader {
3232
loader := new(loader)
3333

3434
if singleflight {

load_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type testLoadCache struct {
3131

3232
func newTestLoadCache(singleflight bool) Cache {
3333
cache := &testLoadCache{
34-
loader: NewLoader(singleflight),
34+
loader: newLoader(singleflight),
3535
}
3636

3737
return cache
@@ -69,12 +69,12 @@ func (tlc *testLoadCache) Load(key string, ttl time.Duration, load func() (value
6969

7070
// go test -v -cover -count=1 -test.cpu=1 -run=^TestNewLoader$
7171
func TestNewLoader(t *testing.T) {
72-
loader := NewLoader(false)
72+
loader := newLoader(false)
7373
if loader.group != nil {
7474
t.Fatalf("loader.group %+v != nil", loader.group)
7575
}
7676

77-
loader = NewLoader(true)
77+
loader = newLoader(true)
7878
if loader.group == nil {
7979
t.Fatal("loader.group == nil")
8080
}

lru.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func newLRUCache(conf *config) Cache {
3939
config: conf,
4040
elementMap: make(map[string]*list.Element, mapInitialCap),
4141
elementList: list.New(),
42-
loader: NewLoader(conf.singleflight),
42+
loader: newLoader(conf.singleflight),
4343
}
4444

4545
return cache

standard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func newStandardCache(conf *config) Cache {
3232
cache := &standardCache{
3333
config: conf,
3434
entries: make(map[string]*entry, mapInitialCap),
35-
loader: NewLoader(conf.singleflight),
35+
loader: newLoader(conf.singleflight),
3636
}
3737

3838
return cache

0 commit comments

Comments
 (0)