0

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!

nowiko
  • 2,507
  • 6
  • 38
  • 82

1 Answers1

1

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/

Community
  • 1
  • 1
moorscode
  • 801
  • 6
  • 13