Search

Settings > Server > Memcached

Memcached is an in-memory key-value store for small chunks of arbitrary data. The Memcached and igbinary PHP extensions are added to your PHP configuration when Memcached is added to your GroupStart servers.

MAMP PRO - Settings - Server - Memcached

When the Memcached server is enabled, the following section is included in the phpInfo (WebStart > Tools -> phpInfo in the MAMP PRO interface) which shows you the configuration options.

MAMP PRO - Servers & Services - Memcached - phpInfo

In the upper right corner of this screen you will find information about the version of the Memcached server and the port used.

  • Use Memcached server
    Select this checkbox if you want the Memcached server to start and stop automatically when the Start/Stop button in the toolbar is clicked. The Memcached PHP extension is automatically included when this option is enabled.

  • Allow network access to Memcached
    Select this checkbox if you want to access the Memcached server over the network. Otherwise, you will not be able to access your Memcached server over the network, even from other locally installed programs.

  • Maximum memory usage:
    Here you can set the size of the maximum available memory.

  • Log level:
    Select how much information should be written to the Memcached log. The following options are available:

    Name Content
    Verbose errors, warnings
    Very Verbose errors, warnings, client commands, responses
    Extremely Verbose errors, warnings, client commands, responses, internal transitions
  • Log file:
    The path to your Memcached log file.

    • Choose…
      Here you can choose the directory and the file name. By default, this log file is located at “/Applications/MAMP/logs/memcached_error.log”.

Examples

The following example shows how to connect to the Memcached server using PHP. The connection can be made either through a UNIX socket or through the network. In the following example, a value (“MAMP PRO”) is stored in the cache and then retrieved.

PHP (Connect using an UNIX socket)

<?php

  /*
    Note:
    The checkbox "Use Memcached server" must be activated under "Settings > Server > Memcached".
  */

  $memcached = new Memcached();

  // Socket
  $memcached->addServer('/Applications/MAMP/tmp/memcached.sock', 0);

  $version = $memcached->getVersion();
  echo '<pre>';
  print_r($version);
  echo '</pre>';

  $memcached->set('Key1', 'MAMP PRO');
  $result = $memcached->get('Key1');
  echo $result;

?>

PHP (Connect via network)

<?php

  /*
    Note:
    The checkbox "Use Memcached server" must be activated under "Settings > Server > Memcached".
  */

  $memcached = new Memcached();

  // Network
  // "Allow network access to Memcached" must be activated.
  // You can set the host to either "127.0.0.1" or "localhost".
  $memcached->addServer('127.0.0.1', 11211);
    
  $version = $memcached->getVersion();
  echo '<pre>';
  print_r($version);
  echo '</pre>';

  $memcached->set('Key1', 'MAMP PRO');
  $result = $memcached->get('Key1');
  echo $result;

?>

Additional information