go-pingbot/ping/cache.go

32 lines
454 B
Go
Raw Permalink Normal View History

2021-09-08 20:18:35 +00:00
package ping
import (
"time"
"github.com/MedzikUser/go-utils/common"
2021-11-10 13:38:54 +00:00
"github.com/medzikuser/go-pingbot/database/mongo"
)
2021-09-05 11:20:19 +00:00
var CacheURL []string
2021-09-05 11:20:19 +00:00
func Cache() {
CacheURL = CacheURL[:0]
err := common.Retry(15, 1*time.Second, func() error {
2021-09-05 10:50:41 +00:00
results, err := mongo.GetAll()
if err != nil {
return err
}
2021-09-05 10:50:41 +00:00
for _, value := range results {
2021-09-05 11:20:19 +00:00
CacheURL = append(CacheURL, value.URL)
2021-09-05 10:50:41 +00:00
}
return nil
})
if err != nil {
log.Error(err)
}
}