generateTokenUlidCommand->execute() . '_' . time(); $data = [ 'id' => $captcha->id, 'coordinators' => $coordinators ]; if (!Cache::driver('redis')->add($key, $data, $expires) ) { throw new DataCaptchaRepositoryException('Could not create cache for captcha: ' . $captcha->id . ' key: ' . $key); } return $key; } public function getByKey(string $key): ?DataCaptcha { $dataCaptcha = Cache::driver('redis')->get($key); if (is_null($dataCaptcha)) { return null; } return new DataCaptcha( captchaId: $dataCaptcha['id'], coordinators: $dataCaptcha['coordinators'], ); } public function destroy(string $key): void { Cache::driver('redis')->delete($key); } }