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).

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!