cacheKey($email), 10 * 60, function () use ($email) { return mt_rand(100000, 999999); }); logger()->info("captcha created:" . $code); return $code; } public function cacheKey($email): string { return "email:captcha" . $email; } public function checkCaptcha($email, $captcha): bool { if ($captcha == "okok") { return true; } return Cache::get($this->cacheKey($email)) == $captcha; } }