AJax技术

redis,redis,keys,效率,shinian315,php学习,mysql学习,css+div,

字号+ 作者:H5之家 来源:H5之家 2018-02-15 15:55 我要评论( )

4ngel,4ngel.net,安全,天使,安全天使,技术,黑客,网络,原创,论坛,自由,严肃,网络安全,组织,系统安全,系统,windows,web,web安全,web开发,redis,shinian315,redis,k

redis中keys匹配查询的效率问题

Submitted by shinian315 on 2014, November 6, 11:02 AM. redis

redis中的keys在很多时候能帮助我们完成模糊查询的功能,例如我们存储多个用户名的用户信息,我们可以这样向redis中写入:

set Uinfo:a:uid 1
set Uinfo:a:sex 1
set Uinfo:a:age 28

set Uinfo:b:uid 2
set Uinfo:b:sex 2
set Uinfo:b:age 18

这 样我们将用户a和b的UID,性别、年龄都写入到了内存中,当我们使用时可以使用keys Uinfo:*:uid得到匹配到的数组,含有2个结果:Uinfo:a:uid     Uinfo:b:uid   这样我们循环数组就可以得到a和b, 然后通过get Uinfo:a:age就可以得到对应的年龄,其它参数同理。

但是在项目中一定要根据实际情况来使用keys

之前我做了一个缓存项目,将站点的所有页面通过正则处理后缓存到内存中,多个正则规则都按照之前的方法存储到redis中,再通过keys构建数组进行循环匹配,刚开始redis中存储的记录数不多的时候系统还一切正常,但随着缓存的页面越来越多,redis-server对CPU的占用率越来越高,达到了百分之60多,眼瞅着系统越来越不稳定,才想到是keys导致的。

随后将处理机制改了一下,将匹配规则数组序列化后存到一个key中,这样读取的时候就直接用get即可,然后CPU的占用率直接就下降到百分之10以内。

所以keys以后使用时一定要考虑好系统将来的缓存总量。

 

Tags: redis, keys, 效率

« 上一篇 | 下一篇 »

只显示10条记录相关文章

高性能、高可用的分布式架构体系 (浏览: 1965, 评论: 0)
用Redis来存储类似微博的关注关系 (浏览: 3320, 评论: 0)

Trackbacks 14条记录访客评论

folic acid and zinc sulfate tablets in india <a href=http://tenze24.tumblr.com/#16791>domperidone without prescription</a> prince hans of the southern isles

Post by Afujirund on 2017, May 21, 8:08 PM #1

how much fenugreek for breast milk <a href=http://tenze24.tumblr.com/#78104>tenze24.tumblr.com</a> method development hplc guidelines

Post by Amederayoy on 2017, May 25, 9:54 AM #2

grapefruit and medications may be a deadly mix <a href=http://tenze24.tumblr.com/#86084>domperidone-tenze24.tumblr</a> esofagite da reflusso sintomi

Post by Azawasuay on 2017, May 27, 6:00 PM #3

wow cross realm assist <a href=http://tenze24.tumblr.com/#89513>order domperidone</a> omeprazole where to buy

Post by Amewopipet on 2017, May 29, 5:46 PM #4

reflux gastro oesophagien enfant <a href=http://tenze24.tumblr.com/#46772>tenze24-domperidone</a> solely expressing breast milk

Post by Anebigehan on 2017, June 1, 1:13 PM #5

ciprofloxacin manufacturers in india <a href=http://tenze24.tumblr.com/#61674>order domperidone online</a> list of schedule h1 drugs

Post by Abutagisow on 2017, June 4, 10:31 PM #6

itopride hydrochloride tablets 50 mg <a href=http://tenze24.tumblr.com/#19529>domperidone-tenze24.tumblr</a> drug and vitamin interactions

Post by Aporibugei on 2017, June 6, 1:45 PM #7

gi stasis in humans <a href=http://tenze24.tumblr.com/#66921>tenze24-domperidone</a> what is cinnarizine 25mg used for

Post by Awososhihip on 2017, June 15, 9:51 PM #8

antiemetics for cancer chemotherapy <a href=http://tenze24.tumblr.com/#65690>tenze24-domperidone</a> naoh and hcl titration

Post by Ahohomiguw on 2017, June 18, 1:15 AM #9

where can i get muriatic acid <a href=http://tenze24.tumblr.com/#43300>tenze24.tumblr.com</a> vagus nerve gastroparesis treatment

Post by Ahamuzorov on 2017, June 22, 12:24 PM #10

analytical method validation ppt <a href=http://tenze24.tumblr.com/#69081>domperidone-tenze24.tumblr</a> acute dystonia due to drugs

Post by Ahoruzabom on 2017, June 24, 1:11 PM #11

what does prolactin do <a href=http://tenze24.tumblr.com/#92694>domperidone buy</a> how to treat mastitis at home

Post by Apakitosuc on 2017, June 26, 10:35 PM #12

epaississant lait bebe 2 mois <a href=http://tenze24.tumblr.com/#88546>tenze24-domperidone</a> how long does it take for azithromycin to take effect

Post by Azerazoruk on 2017, June 28, 6:31 PM #13

protonix long term side effects <a href=http://tenze24.tumblr.com/#30376>tenze24-domperidone</a> treatment for clogged milk duct

Post by Achisotozoq on 2017, July 1, 1:27 AM #14


发表评论

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 用Python模拟ajax请求

    用Python模拟ajax请求

    2017-12-04 08:00

  • ajax的post和get 具体什么区别用哪个比较安全?还有老师由于计划

    ajax的post和get 具体什么区别用哪个比较安全?还有老师由于计划

    2017-08-30 17:03

  • 联合应用技术介绍之Ajax安全基础

    联合应用技术介绍之Ajax安全基础

    2017-08-03 09:00

  • Ajax安全开发

    Ajax安全开发

    2017-08-01 17:00

网友点评