Troubleshooting

Test Memcached

You can test your Memcached installation with a client like php-memcached-sasl, a simple Memcached client written in PHP.

NOTE: The Bitnami Memcached Stack does not include PHP. To use the example script below, you must have PHP installed on your machine. You can install PHP in your machine (refer to PHP Official Documentation for more information regarding how to install it), or you can launch a new server with PHP using the Bitnami LAMP Stack.

Download the php-memcached-sasl client from this link and begin by extracting the contents of the downloaded archive. The archive includes a simple script named example.php.

The script begins by including the necessary PHP class and instantiating an object of the class:

include('MemcacheSASL.php');
$m = new MemcacheSASL;

Now, you have to connect to Memcached. In order to connect to the Memcached, you have two options:

(Recommended): Access Memcached through an SSH tunnel (refer to the FAQ for more information about SSH tunnels).

Open the port 11211 for remote access (refer to the FAQ for more information about opening ports).

IMPORTANT: Making this application’s network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks. If, for development purposes, you need to access from outside of a trusted network, please do not allow access to those ports via a public IP address. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

Once you have an active SSH tunnel or you opened the port for remote access, configure the client object by defining the Memcached server host and port, and SASL configuration. Replace these values in the script with actual values for your server:

You can now use the object’s add() and get() methods to add or remove values from the cache. In this example, the add() method stores the value ‘12345’ using the key ‘test’. The key can then be used with the get() method to retrieve the original value whenever needed.