Skip to content

Commit 5a62ec8

Browse files
committed
将 Loader 改成 loader 私有的
1 parent fd7f297 commit 5a62ec8

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

HISTORY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
> 此版本发布于 2024-01-13
66
7-
* 受小徒弟的灵感激发,进行 Loader 代码的调整
7+
* 受小徒弟的灵感激发,进行 loader 代码的调整
88
* 把 cache 结构去掉,精简这部分设计
99

1010
### v0.5.0

cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727

2828
type testCache struct {
2929
*config
30-
loader *Loader
30+
loader *loader
3131

3232
count int32
3333
}

lfu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type lfuCache struct {
2828
itemHeap *heap.Heap
2929
lock sync.RWMutex
3030

31-
loader *Loader
31+
loader *loader
3232
}
3333

3434
func newLFUCache(conf *config) Cache {

load.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121
flight "github.com/FishGoddess/cachego/pkg/singleflight"
2222
)
2323

24-
// Loader loads values from somewhere.
25-
type Loader struct {
24+
// loader loads values from somewhere.
25+
type loader struct {
2626
group *flight.Group
2727
}
2828

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

3434
if singleflight {
3535
loader.group = flight.NewGroup(mapInitialCap)
@@ -39,7 +39,7 @@ func NewLoader(singleflight bool) *Loader {
3939
}
4040

4141
// Load loads a value of key with ttl and returns an error if failed.
42-
func (l *Loader) Load(key string, ttl time.Duration, load func() (value interface{}, err error)) (value interface{}, err error) {
42+
func (l *loader) Load(key string, ttl time.Duration, load func() (value interface{}, err error)) (value interface{}, err error) {
4343
if load == nil {
4444
return nil, errors.New("cachego: load function is nil in loader")
4545
}
@@ -52,7 +52,7 @@ func (l *Loader) Load(key string, ttl time.Duration, load func() (value interfac
5252
}
5353

5454
// Reset resets loader to initial status which is like a new loader.
55-
func (l *Loader) Reset() {
55+
func (l *loader) Reset() {
5656
if l.group != nil {
5757
l.group.Reset()
5858
}

load_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type testLoadCache struct {
2626
value interface{}
2727
ttl time.Duration
2828

29-
loader *Loader
29+
loader *loader
3030
}
3131

3232
func newTestLoadCache(singleflight bool) Cache {

lru.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type lruCache struct {
2727
elementList *list.List
2828
lock sync.RWMutex
2929

30-
loader *Loader
30+
loader *loader
3131
}
3232

3333
func newLRUCache(conf *config) Cache {

standard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type standardCache struct {
2525
entries map[string]*entry
2626
lock sync.RWMutex
2727

28-
loader *Loader
28+
loader *loader
2929
}
3030

3131
func newStandardCache(conf *config) Cache {

0 commit comments

Comments
 (0)