Setting up Vivvo Memcache

Vivvo does not “setup” memcache (or memcached) servers. Your server administrator must install and maintain functionality of your instances.

You need to know where they are (IP addresses) and ports they operate in order to set and use Vivvo Memcache capabilities.

What is Memcached?

Memcached is high-performance distributed memory caching system that provides tremendous speed ups in web applications, and Vivvo Memcache driver uses that power to run way faster than any other caching mechanism available in current version.

There are two different memcache modules for PHP:

both supported by Vivvo Memcache application driver. You need to know what is installed on your server(s).

Configure Memcache driver

Configuring requires a basic knowledge of JSON format. If you are not familiar with JSON, please harvest a basic understanding how parameters can be set in your conf.php file in order to set it right. You can start from here for JSON conventions.

However, it is very easy to setup Vivvo Memcache and it requires to create two constants in conf.php and write your parameters. Default configuration looks like this (assuming you have Memcache running):

...
define('VIVVO_SYSTEM_CACHE_DRIVER', 'Memcache');
define('VIVVO_SYSTEM_CACHE_DRIVER_PARAMS', '{
"Memcache":{
  "servers":[
    {"host":"127.0.0.1", "port":11211, "persistent":false}
    ],
  "compression":false,
  "namespace":"vivvo",
  "lifetime":0
  }
}');
...

Constants and Parameters

Only two constants should be added in conf.php file:

  • VIVVO_SYSTEM_CACHE_DRIVER - with value 'Memcache' or 'Memcached' (consult your system administrator)
  • VIVVO_SYSTEM_CACHE_DRIVER_PARAMS - with JSON string (parameters)

Parameters explained:

  • servers - this is a list of AT LEAST ONE memcache instances you want to use. Default setup is:
    • {“host”:“127.0.0.1”, “port”:11211}
  • compression - Memcache has ability to compress the data using zlib compression. ZLib library must be installed and PHP properly configured to use it. This value is not required and default is false
  • namespace - a unique identifier for all items should be cached. By default is vivvo, but you can change it to something more meaningful if you like. Keep it short.
  • lifetime - a number (milliseconds). Cached items will not be invalidated until that time. It means, how much time should they stay on Memcached servers. Default value is 0 (never expire), and max limit is 30 days

Memcache(d) servers must have minimum parameters:

  • host - host name, or IP address (recommended) for this server. Value is required
  • port - on which port it runs (default is 11211)

For Memcache additional parameter is:

  • persistent - controls persistent connection for a Memcache server (default is false)

For Memcached additional parameter is:

  • weight - probability of using this server. Default is 1 (cannot be 0)

Now, if you want to use more than one server, you can simply add them to your conf.php in “servers” directive: For example, single machine but different ports:

...
"servers":[
  {"host":"127.0.0.1"}, // port 11211 (default)
  {"host":"127.0.0.1", "port":11212, "persistent":true}, // if memcache
  {"host":"127.0.0.1", "port":11213}
  ],
...

or running on different machines on port 11211:

...
"servers":[
  {"host":"127.0.0.1"},
  {"host":"127.0.0.2"},
  {"host":"127.0.0.3"}
  ],
...

Vivvo Memcache notes

Vivvo Memcache driver runs out of the box with default setup, but for best performances it is recommended to find your perfect config/server combination before you go on production. Experiment a bit with compression parameter, or persistent for each instance.

Every server behave differently as this depends on it's setup and applies to every memcached instance. There are many versions of Memcache(d) and some very unstable. Be careful what you intend to use out there.

 
installation/memcache.txt · Last modified: 2010/04/14 09:24 by boccio
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki