momentohq / drupal-cache
Installs: 265
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:drupal-module
Requires
- momentohq/client-sdk-php: 1.7.1
- dev-main
- v0.5.5
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-release-please--branches--main--components--drupal-cache
- dev-update-license
- dev-chore/nogrpc
- dev-benchmark-no-logging
- dev-benchmark-1
- dev-disable-dblog
- dev-force-new-channel-false
- dev-cache-name-in-settings
- dev-check-cache-in-client-factory
- dev-add-limits-to-readme
- dev-clear-cache-testing
- dev-remove-unused-invalidator
- dev-interface-work
- dev-invalidation-work
- dev-php7-testing
This package is auto-updated.
Last update: 2024-12-07 00:16:26 UTC
README
Prerequisites
A Momento API Token is required. You can generate one using the Momento Console.
The Momento Cache module uses Momento's PHP SDK internally. While installing the Drupal module will automatically install the SDK for you. Separately, you will need to install and enable the following extensions:
- The PHP gRPC extension for the SDK to function.
- The C Protobuf extension for PHP.
A Momento cache is required to handle Drupal's caching requests. You can create a cache in the Momento Console.
Drupal and Momento Rate Limiting
Momento's free tier limits accounts' transactions per second (TPS) and
throughput (KiBps), and requests that exceed those limits are throttled.
While the default limits are fine for exploring and developing with
the Momento integration, Drupal's usage of the cache backend can be
significantly higher than the default throttling limits under load.
Prior to using the integration in a high-traffic or production environment,
please reach out to support@momentohq.com
to raise your account limits.
You can check the Drupal dblog and/or the logfile you configure in the
settings (instructions below) for rate limiting error messages.
Installation and Configuration
Add the module with composer require 'momentohq/drupal-cache:0.5.2'
.
Enable the momento_cache
module in your Drupal administrator interface
or using drush en momento_cache
.
Add the following to your settings.php
file:
$settings['cache']['default'] = 'cache.backend.momento_cache'; $settings['momento_cache']['api_token'] = '<YOUR_MOMENTO_TOKEN>'; $settings['momento_cache']['cache_name'] = '<YOUR_CACHE_NAME>'; $settings['momento_cache']['logfile'] = '<YOUR_LOG_FILE_PATH>';
Replace <YOUR_MOMENTO_TOKEN>
with the token you generated in the console.
You may also use an environment variable named MOMENTO_API_TOKEN
to pass
your API token to the Momento cache backend. If both are supplied,
the settings file takes precedence.
Replace <YOUR_CACHE_NAME>
with the name of your existing Momento cache.
You may also use an environment variable named MOMENTO_CACHE_NAME
to pass this value. If both are supplied, the settings file takes precedence.
You must create the cache before using the module.
If the cache doesn't exist, errors are written to the Drupal dblog
as well as the logfile configured in your settings, if you have specified one.
Replace <YOUR_LOG_FILE_PATH>
with the path of a file writable by your
Drupal server or with null
if you want to suppress logging.
This logfile is used for logging and timing requests as they are handled
by the module. Please be aware that this file will grow quickly over time,
so if you choose to enable it long-term, you should probably
use logrotate
or some similar utility to keep it from
growing out of control.
The example above uses Momento for all Drupal caches. If you prefer
to use Momento for specific cache bins, you may assign them
individually as well:
$settings['cache']['bins']['render'] = 'cache.backend.momento_cache'