当前位置:网站首页>从海量手机号中匹配某一个手机号
从海量手机号中匹配某一个手机号
2022-06-25 09:32:00 【进阶的小橙子】
1-需求背景:有10w个手机号黑名单,每次打车之前,都要校验一下当前用户是否在这个10w个黑名单内,如果在则提示拦截,无法打车,否则放行
2-技术实现分析:
1-将这10w个手机号,放在mysql数据库表中,每次查询都从数据库查询是否存在,在则返回有,否则返回无
2-将这10w个手机号,放在redis缓存中,定义一个searchKey,将手机号拼接成一个大字符串,当value存入,每次通过searchKey来查找,然后通过contains来判断是否存在
以上2中方案被迅速pass,因为手机号越来越多,按照1000个字符=1k,10w=100k,后面越来越多,占用内存空间也就越来越大,查找速度也越来越慢
最新方案
3-采用布隆过滤器,将10w个手机号,使用pipeline方式,遍历的塞入redis,用setBit方法存入,其实存入的是每个手机号的hashCode,然后丢入一个手机号进行匹配,匹配到了则返回有,否则返回无
4-用redis的set,根据手机尾号最后一位,将手机号分成10批,生成10个searchKey,如searchKey1,searchKey2.。。。。searchKey10,然后将10批手机号set当成value,分别存入对应的searchKey下,当判断一个手机号是否存在时,先根据尾号判断在哪一个searchKey,然后再取value来进行判断
以上第3中方案,效率极高,因为存值为bit位图,占用空间很少,且匹配速度极快,但是准确率不足,可能放入的手机号判断不准,因为不同的手机号,得到的hashCode可能一致。如果可以容错则考虑
最终采用第4种方案,能保障准确性,且能最大程度加快匹配速度,最均衡。
具体采用哪一种方案还是要看实际使用场景
边栏推荐
- 十大券商开户风险大吗,安全靠谱吗?
- When unity released webgl, jsonconvert Serializeobject() conversion failed
- 1、 Construction of single neural network
- 203 postgraduate entrance examination Japanese self-study postgraduate entrance examination experience post; Can I learn Japanese by myself?
- Matplotlib plt grid()
- Japanese online notes for postgraduate entrance examination (9): composition template
- 3、 Automatically terminate training
- Notes on key words in the original English work biography of jobs (III) [chapter one]
- The meshgrid() function in numpy
- Socket programming -- epoll model
猜你喜欢

2022 postgraduate entrance examination experience post -- Alibaba Business School of Hangzhou Normal University -- management science and Engineering (including the recommendation of books and course

matplotlib 简单逻辑回归可视化
![[project part - structure and content writing of technical scheme] software system type mass entrepreneurship and innovation project plan and Xinmiao guochuang (Dachuang) application](/img/4a/1e83ea9e8e79c0ae7244a159943480.jpg)
[project part - structure and content writing of technical scheme] software system type mass entrepreneurship and innovation project plan and Xinmiao guochuang (Dachuang) application

Analysis on the thinking of 2022 meisai C question

Title B of the certification cup of the pistar cluster in the Ibagu catalog
![[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition](/img/b4/84c30ed112c4dffd8d51697b2f4a4f.jpg)
[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition

How can games copied from other people's libraries be displayed in their own libraries

TLAB mechanism of JVM object memory allocation and TLAB process in G1

2022 meisai question a idea sharing

2021mathorcupc topic optimal design of heat dissipation for submarine data center
随机推荐
[project part - structure and content writing of technical scheme] software system type mass entrepreneurship and innovation project plan and Xinmiao guochuang (Dachuang) application
Matplotlib axvline() and axhline() functions in Matplotlib
Is it safe for Huatai Securities to open an account on it? Is it reliable?
SQL advanced
matplotlib matplotlib中plt.grid()
十大券商开户风险大吗,安全靠谱吗?
Analysis on the thinking of 2022 meisai C question
matplotlib matplotlib中决策边界绘制函数plot_decision_boundary和plt.contourf函数详解
Voiceprint Technology (III): voiceprint recognition technology
使用Navicat对比多环境数据库数据差异和结构差异,以及自动DML和DDL脚本
The first techo day Tencent technology open day, 628 waiting for you!
自定义注解之编译时注解(RetentionPolicy.CLASS)
How annotation lib and processor lib reference
[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition
22 mathematical modeling contest 22 contest C
Jmeter中的断言使用讲解
《乔布斯传》英文原著重点词汇笔记(二)【 chapter one】
2、 Training fashion_ MNIST dataset
How much money have I made by sticking to fixed investment for 3 years?
Notes on key words in the original English work biography of jobs (V) [chapter three]