To answer your question: Yes, you can call AuthTasker.cleanToken () every second using the schedule method. I recommend the following (including import for you):
import scala.concurrent.duration._ import scala.concurrent.ExecutionContext import ExecutionContext.Implicits.global val system = akka.actor.ActorSystem("system") system.scheduler.schedule(0 seconds, 1 seconds)(AuthTasker.cleanTokens)
Note. This updated code calls the scheduled method every second, not every 0 seconds. I caught an error while paying attention to the code.
source share