check_hash_storage.go 625 B

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