index_cache.go 792 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package cache
  2. import (
  3. "context"
  4. "fmt"
  5. "hongze/mysteel_watch/global"
  6. )
  7. // record more information
  8. //func IndexAutoRefresh(filePath string) bool {
  9. // if global.Re == nil {
  10. // if global.Rc != nil {
  11. // if global.Rc.SetNX(filePath, filePath, utils.GetTodayLastSecond()) {
  12. // err := global.Rc.LPush(utils.REFRESH_INDEX, filePath)
  13. // if err != nil {
  14. // fmt.Println("RecordNewLogs LPush Err:" + err.Error())
  15. // }
  16. // return true
  17. // }
  18. // }
  19. // return false
  20. // }
  21. // return false
  22. //}
  23. func IndexAutoRefresh(filePath string) bool {
  24. channel := `autoRefresh`
  25. if global.Redis != nil {
  26. err := global.Redis.Publish(context.TODO(), channel, filePath).Err()
  27. if err != nil {
  28. fmt.Println("Redis.Publish Err:" + err.Error())
  29. return false
  30. }
  31. return true
  32. }
  33. return false
  34. }