【发布时间】:2017-11-03 16:27:47
【问题描述】:
我使用 spring-boot 框架开发了一个应用程序 java。在我的课堂上,在保存用户之前,我需要检查他的电子邮件是否存在于 1000 封电子邮件的列表中,如果检查正常,我必须设置一个布尔值,表明该用户是 loyel 用户。
我的问题是在短时间内检查用户电子邮件是否存在于该列表中的最佳实施是什么:
1- Read a file that contain the 1000 emails each time when a user will be created. What is the best way to do that without read every time the file ?
using a singleton....
2- Create an email ArrayList and parse it each time ???
3. create a database and make a request to check each time if the email exists
你有什么建议吗?
最好的问候
【问题讨论】:
-
“最好的方法”是什么意思?性能最好?可维护性?你的教师学位?更少的代码?
-
我的意思是性能和速度
-
请澄清。什么速度?你打算使用 clasters 吗?您确定会有 1,000 封电子邮件,而不是 1,001 封吗?
-
我有一个包含 1000 封电子邮件的固定列表。当用户询问 API createUser 时,我需要检查他的电子邮件是否在该列表中。如果检查正常,我将设置一个布尔值,表明他是我公司的老用户。我的问题是,就时间而言,获得该布尔值(存在与否)的最快实现是什么。
标签: java spring spring-boot