0

I am building a caching system using memcache and was wondering what is the best format to store data.

Considering network latency since my memcache server is not on local host but on a centralized server. I found, storing a formatted array takes up 3× the size of a json_encoded array. So a 150kb php array becomes 50kb json encoded. Great!.

On average, each request performs roughly around 10 calls to memcache (for a number of reasons) which means it will have to decode data 10 times. am i ultimately loosing performance?

sam
  • 5
  • 1
  • 6
  • Question is not a duplicate. I am not serializing the array. Its just php array array("name" => "sam"). So reading the data back requires no unserialize making it faster to read. – sam Jul 07 '17 at 12:52
  • 1
    As memcached has no idea what a PHP array looks like, it can only store it in a form that it does recognise, such as serialized or json format (ie as a string) – Mark Baker Jul 07 '17 at 12:58
  • @mark i think you missing the point. We can store anything in memcache in whatever format, but parsing the data back is where i am most concern about. Like i said, i can store a formatted array in memcache and read the data back just as it is, it requires no unserialize. So, if i format my data like this array("name" => "sam"), i can read it back as the same. Just that this method is 3x larger than json encoded. So that brings network performance into play. But again, if the data is json encoded, i will have to decode it. So i am trying to figure out which is better – sam Jul 07 '17 at 13:08
  • So what is the problem you have with the answers to the linked duplicate question? – Mark Baker Jul 07 '17 at 13:26

0 Answers0