check_hash_storage.go 633 B

12345678910111213141516171819202122
  1. package job
  2. import "github.com/mhsanaei/3x-ui/v3/internal/web/service/tgbot"
  3. // CheckHashStorageJob periodically cleans up expired hash entries from the Telegram bot's hash storage.
  4. type CheckHashStorageJob struct {
  5. tgbotService tgbot.Tgbot
  6. }
  7. // NewCheckHashStorageJob creates a new hash storage cleanup job instance.
  8. func NewCheckHashStorageJob() *CheckHashStorageJob {
  9. return new(CheckHashStorageJob)
  10. }
  11. // Run removes expired hash entries from the Telegram bot's hash storage.
  12. func (j *CheckHashStorageJob) Run() {
  13. storage := j.tgbotService.GetHashStorage()
  14. if storage == nil {
  15. return
  16. }
  17. storage.RemoveExpiredHashes()
  18. }