Memcached best practices - small objects and lots of keys or big objects and few keys?

前端 未结 6 1795
梦谈多话
梦谈多话 2021-02-02 11:23

I use memcached to store the integer result of a complex calculation. I\'ve got hundreds of integer objects that I could cache! Should I cache them under a single key in a more

6条回答
  •  暖寄归人
    2021-02-02 11:30

    It depends on what are those numbers. If you could, for example, group them in ranges, then you could optimize the storage. If you could hash them, into a map, or hashtable and store that map serialized in memcached would be good to.

    Anyway, you can save many little keys, just make sure you configure the slabs to have chunks with small size, so you will not waste memory space.

提交回复
热议问题