duanchi1230 2015-11-15 21:07
浏览 58
已采纳

在Memcached中正确存储数据

I am using Memchache for storing some data, and single item in memcahce looks like the following structure:

`locale1` => [
   'domain1' => [
        'key1-1' => 'value1-1',
        'key1-2' => 'value1-2'
    ],
   'domain2' => [ ... ]
]

so in memcache I have multiple items with similar keys, values that lays in side locale->domain can be changed by web interface. My question is:

What if I will place all locales to single memcache item called locales_holder, and then will fetch all data from it, would it be critical to performance or its ok?

Thanks!

  • 写回答

1条回答 默认 最新

  • dongzhao1865 2015-11-15 21:40
    关注

    This would not be very efficient. Memcache deletes keys that are not used often or when space is needed.

    Building the keys and storing small to medium sized data gives the best results.

    Memcache key: locale/domain1/key1/1
    Memcache value: 'value1-1'
    

    Whenever something gets changed you don't have to write the entire blob of data back into the memcache instance.

    Also, if you are using multiple servers the data gets distributed better over the servers because it can split up the entire locale section over multiple servers.

    If you have two servers, the memcached client calculates a numeric value from the key and performs a simple calculation on it (for example, modulus) to determine whether it should store the value on the first, or second, configured memcached instance.

    See also: - Memcached best practices - small objects and lots of keys or big objects and few keys? - http://www.ibm.com/developerworks/library/os-memcached/

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

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿