index_cache.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package cache
  2. import (
  3. "container/list"
  4. "sync"
  5. )
  6. //// AddIndexRefreshExcel 添加刷新excel队列
  7. //func AddIndexRefreshExcel(filePath string) bool {
  8. // if global.Re == nil {
  9. // if global.Rc != nil {
  10. // err := global.Rc.LPush(utils.REFRESH_HONGTAO_EXCEL, filePath)
  11. // if err != nil {
  12. // fmt.Println("Add Index Reresh Excel LPush Err:" + err.Error())
  13. // }
  14. // return true
  15. // }
  16. // return true
  17. // }
  18. // return false
  19. //}
  20. // RefreshList 刷新的列表
  21. var RefreshList *list.List
  22. func init() {
  23. RefreshList = list.New()
  24. }
  25. var FilePathMap = make(map[string]int)
  26. // FilePathMutex 创建一个互斥锁
  27. var FilePathMutex sync.Mutex
  28. // AddIndexRefreshExcel
  29. // @Description: 添加刷新excel队列
  30. // @author: Roc
  31. // @datetime2023-10-31 09:40:30
  32. // @param filePath string
  33. func AddIndexRefreshExcel(filePath string) {
  34. FilePathMutex.Lock()
  35. defer FilePathMutex.Unlock()
  36. // 如果存在该路径,那么就不记录入list
  37. if _, ok := FilePathMap[filePath]; ok {
  38. return
  39. }
  40. RefreshList.PushBack(filePath)
  41. FilePathMap[filePath] = 1
  42. return
  43. }