Create a Drupal application. If you are not sure how to do it, refer to the page First Application.
memcached, you will need access to the
Resources tab. The
Resources tab is disabled by default and can only be enabled by admins.
The following steps show you how to enable the
Resources tab if you have admin access already.
Once the application is created, go to the "Settings" tab on the top panel:
On the right of the "Basic Information" section, click "Edit":
This will open a dialog for editing the "Basic information":
You might need special permissions to change the application type.
After that, the "Resouces" tab, which was previously disabled, will become available. Click on it, and, once there, click on "Create Memcached" to create a Memcached instance for your application:
A Memcached instance will appear under "Existing services":
composer require drupal/memcache drush en -y memcache
sites/default/settings.php) and add the following lines to the end of the file:
$settings['memcache']['servers'] = ['MEMCACHED_HOST:11211' => 'default']; $settings['memcache']['bins'] = ['default' => 'default']; $settings['memcache']['key_prefix'] = '<random_string>'; $settings['cache']['default'] = 'cache.backend.memcache'; $settings['cache']['bins']['render'] = 'cache.backend.memcache';
MEMCACHED_HOST in the first line of the snippet above with the "host" value retrievied from the Memcached "Instance information" in the "Resources" tab as described at the end of the previous section. If the port name is different from the default
11211, replace it as well. After that, the first line of the code snippet above will look similar to this:
$settings['memcache']['servers'] = ['dp-mem-6138daae90f47f00146c3b49.devpanel-beta-1603957455987ynrthjbag.svc.cluster.local:11211' => 'default'];
NOTE: Multiple applications and sites can use the same memcached resource as long as each of them is using a different
key_prefixrandom string value
Save your changes to settings.php.
By default, the permissions of settings.php are set to read-only, so VSCode might ask you if it is OK to overwrite the file bypassing the permissions. Confirm this operation.
Now your Drupal application is configured to use Memcached!
To make sure that Memcached is really working, you may need to install the
Memcache Admin module using Drupal's admin interface. After that, the "Memcache statistics" will appear in the "Reports". It will contain the parameters of your memcached instance along with the gets/hits/misses counters.
If the memcached parameters added to settings.php are incorrect or the memcached instance is not working properly, the "Memcache statistics" will report about a configuration error and the following message will be displayed:
There may be a problem with your Memcache configuration. Please review README.txt for more information.