package cache import ( "container/list" "sync" ) // record more information //func IndexAutoRefresh(filePath string) bool { // if global.Re == nil { // if global.Rc != nil { // if global.Rc.SetNX(filePath, filePath, utils.GetTodayLastSecond()) { // err := global.Rc.LPush(utils.REFRESH_INDEX, filePath) // if err != nil { // fmt.Println("RecordNewLogs LPush Err:" + err.Error()) // } // return true // } // } // return false // } // return false //} //func IndexAutoRefresh(filePath string) bool { // channel := `autoRefresh` // if global.Redis != nil { // err := global.Redis.Publish(context.TODO(), channel, filePath).Err() // if err != nil { // fmt.Println("Redis.Publish Err:" + err.Error()) // return false // } // return true // } // return false //} // RefreshList 刷新的列表 var RefreshList *list.List func init() { RefreshList = list.New() } var FilePathMap = make(map[string]int) // FilePathMutex 创建一个互斥锁 var FilePathMutex sync.Mutex func IndexAutoRefresh(filePath string) { FilePathMutex.Lock() defer FilePathMutex.Unlock() // 如果存在该路径,那么就不记录入list if _, ok := FilePathMap[filePath]; ok { return } RefreshList.PushBack(filePath) FilePathMap[filePath] = 1 return }