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