MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / initList

Method initList

internal/caches/storage_file.go:1027–1076  ·  view source on GitHub ↗

初始化List

()

Source from the content-addressed store, hash-verified

1025
1026// 初始化List
1027func (this *FileStorage) initList() error {
1028 err := this.list.Reset()
1029 if err != nil {
1030 return err
1031 }
1032
1033 // 使用异步防止阻塞主线程
1034 /**goman.New(func() {
1035 dir := this.dir()
1036
1037 // 清除tmp
1038 // TODO 需要一个更加高效的实现
1039 })**/
1040
1041 // 启动定时清理任务
1042 this.initPurgeTicker()
1043
1044 // 热点处理任务
1045 this.hotTicker = utils.NewTicker(1 * time.Minute)
1046 if Tea.IsTesting() {
1047 this.hotTicker = utils.NewTicker(10 * time.Second)
1048 }
1049 goman.New(func() {
1050 for this.hotTicker.Next() {
1051 trackers.Run("FILE_CACHE_STORAGE_HOT_LOOP", func() {
1052 this.hotLoop()
1053 })
1054 }
1055 })
1056
1057 // 退出时停止
1058 events.OnKey(events.EventQuit, this, func() {
1059 remotelogs.Println("CACHE", "quit clean timer")
1060
1061 {
1062 var ticker = this.purgeTicker
1063 if ticker != nil {
1064 ticker.Stop()
1065 }
1066 }
1067 {
1068 var ticker = this.hotTicker
1069 if ticker != nil {
1070 ticker.Stop()
1071 }
1072 }
1073 })
1074
1075 return nil
1076}
1077
1078// 清理任务
1079// TODO purge每个分区

Callers 1

InitMethod · 0.95

Calls 10

initPurgeTickerMethod · 0.95
hotLoopMethod · 0.95
NewTickerFunction · 0.92
NewFunction · 0.92
RunFunction · 0.92
OnKeyFunction · 0.92
PrintlnFunction · 0.92
NextMethod · 0.80
ResetMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected