首页 > 技术相关, 数据库 > Redis实现之虚拟存储系统(VM)实现(二)–数据交换(Swap)的实现


2011年7月17日 发表评论 阅读评论

Redis的虚拟存储系统(VM subsystem)的目的是实现将Redis对象(Redis Objects)方便的在主存(Memory)和硬盘(Disk)之间交换。在Redis虚拟存储系统中,Redis仅仅会将和值(Values)关联的对象交换(swap)到硬盘上。在前一篇日志中,对VM涉及的数据结构进行简要介绍,在这篇日志中,将介绍数据交换的具体过程。


 vm-page-size 32
vm-pages 134217728




  1. 找出需要多少页来存储交换文件。这仅仅需要通过调用rdbSavedObjectPages函数即可返回需要的页数。
  2. 知道需要的页数后,我们需要找到交换空间中一些连续的页来存储。这是通过vmFindContiguousPages函数实现的。这个函数有可能因为内存满了而失败,也有可能因为找不到连续的页失败。当这种情况发生时,交换将被取消,数据将继续保存在内存中。
  3. 最终,我们只需要调用vmWriteObjectOnSwap函数即可以将数据交换到对应的位置。数据交换完成后,对应的主存被释放,对应的key也被标记为REDIS_VM_SWAPPED,而对应的页表位向量也被标记为使用中。


本文作者: Sigma    在新浪微博关注SigmaSigmaWeibo    RSS订阅本博客
本文链接: http://www.sigma.me/2011/07/17/redis-vm-implement-swap-processing.html

  1. 2011年7月24日02:21 | #1


  2. 2011年7月24日06:07 | #2




  3. 2011年7月23日08:43 | #3


  4. 2011年8月17日06:07 | #4


  5. 2019年1月9日11:57 | #5

    I precisely desired to say thanks yet again. I am not sure what I could possibly have used without those thoughts shown by you about my subject. It had become an absolute challenging crisis in my circumstances, nevertheless finding out your well-written way you dealt with it took me to cry for joy. I will be happy for your help and in addition hope that you realize what a great job you’re getting into instructing the rest via a site. Probably you haven’t met any of us.

  6. 2019年1月10日08:47 | #6

    Needed to post you this bit of remark in order to give thanks yet again with the wonderful solutions you have discussed in this case. It has been really pretty generous of you to supply unreservedly exactly what a few individuals could possibly have advertised for an ebook to help make some dough for themselves, precisely considering the fact that you could have done it in case you decided. The inspiring ideas as well worked to be the easy way to be sure that most people have similar dream really like my own to understand significantly more on the subject of this condition. Certainly there are several more enjoyable sessions up front for folks who see your blog post.

  7. 2019年1月11日00:57 | #7

    I precisely wanted to appreciate you once more. I’m not certain the things that I would’ve implemented in the absence of those information contributed by you over such problem. It had been the depressing condition for me, nevertheless witnessing the very specialised avenue you resolved it made me to leap for joy. I am just happier for the support and in addition hope that you recognize what an amazing job your are putting in teaching others through the use of your webblog. I am certain you haven’t encountered all of us.

  8. 2019年1月11日04:52 | #8

    Thanks for all of your labor on this web page. Kate take interest in participating in investigation and it’s really easy to see why. I notice all relating to the lively method you deliver effective guides via this web site and as well as attract contribution from other individuals on this issue while our favorite child is always becoming educated a great deal. Take advantage of the remaining portion of the year. You’re conducting a really great job.

  9. 2019年1月12日00:29 | #9

    Thanks for all your effort on this website. Gloria really loves conducting research and it is obvious why. I notice all relating to the compelling tactic you present very useful thoughts on the blog and welcome response from some other people on this content plus our favorite daughter is always discovering a great deal. Have fun with the rest of the year. You are always doing a fantastic job.

  10. 2019年1月12日16:43 | #10

    I precisely needed to thank you very much yet again. I am not sure the things that I would’ve used in the absence of the entire basics revealed by you on such question. It has been the depressing problem in my view, but taking a look at the very well-written style you treated the issue made me to weep for contentment. Now i’m happier for the help and then have high hopes you really know what an amazing job your are putting in teaching the others all through your website. More than likely you’ve never encountered any of us.

  11. 2019年1月13日11:43 | #11

    Thank you for your whole effort on this web site. My mum take interest in getting into internet research and it’s easy to understand why. Almost all notice all concerning the lively manner you convey very important things by means of this blog and therefore attract response from other people on that article and our own daughter is without question learning so much. Take advantage of the remaining portion of the year. You are always doing a tremendous job.

  12. 2019年1月14日07:12 | #12

    I together with my buddies happened to be digesting the best tips and tricks located on the blog and before long developed a terrible suspicion I never thanked the website owner for those tips. All of the young men are already certainly glad to learn all of them and have now simply been taking pleasure in these things. Appreciation for actually being really kind and for opting for some ideal resources millions of individuals are really wanting to learn about. Our honest regret for not expressing appreciation to sooner.

  1. 本文目前尚无任何 trackbacks 和 pingbacks.