dpvhv66448 2011-02-25 06:36
浏览 32
已采纳

PHP memcached,真正的特权是什么?

I just installed memcached and tried a couple of sample code found on php.net but since I'm a newbie on this, i dont get the advantage of using it, where I can store the same data in a session or cookie..

for instance I run a real estate website where users do a lot of searches / queries to mysql and lot of ajax queries

as far as i understood i can chace those queries...but what happen if the results change because someone posted a new ad? how can memcached know that?

so, question is, why should I use it and in wich occasions?

thanks!

  • 写回答

1条回答 默认 最新

  • douzhuan1169 2011-02-25 06:55
    关注

    You have to know what to cache and what not to cache. To take your example, say your site gets insanely poplar and you have a 100 million real estate listings. And you have millions of users doing searches and looking at the details. That's a lot of queries!

    Enter Memcached, if you (for example) cache the detailed listing view in Memcached by saving the results of that query, you cut down the amount of load. This is because, apart from the first time where the server queried MySQL, every other hit is on Memcached.

    Another thing you could do is save the results of the searches by storing the search query hash as the key. Depending on how much memory you have, that again would decrease load because Memcached is simply serving up the cached pages.

    It's up to you to decide how long you're going to keep the cache as well as how your invalidation scheme would run (maybe clear the key when you add a new property, or only updates once a day).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了