Install Redis cache
2 minute read
For better performance and scalability, you can configure API Portal to cache APIs in a Redis cache. Using a Redis cache is recommended if you plan to expose hundreds of APIs, or you plan to connect API Portal to more than one API Manager.
Install Redis on Red Hat 7 (RHEL 7) using RHSCL
-
Enable
rhel-server-rhscl-7-rpms
andrhel-7-server-optional-rpms
repositories from RHSCL:sudo subscription-manager repos --enable rhel-server-rhscl-7-rpms sudo subscription-manager repos --enable rhel-7-server-optional-rpms sudo yum clean all
-
Install Redis:
sudo yum install rh-redis5
-
Enable Redis executables in any bash session by default:
echo "source scl_source enable rh-redis5" | sudo tee -a /etc/profile.d/scl-redis5.sh source /etc/profile.d/scl-redis5.sh
-
Enable and start the Redis service:
sudo systemctl enable --now rh-redis5-redis
-
Verify the Redis service is active:
systemctl status rh-redis5-redis
-
Install
rh-php73-php-devel
andrh-php73-php-pear
to enablepecl
(which manages external PHP modules) andphpize
(which will buildredis
PHP module)`:sudo yum install rh-php73-php-devel rh-php73-php-pear sudo ln -s $(which pecl) /usr/bin
-
Install and enable
redis
PHP module:sudo pecl install redis echo "extension=redis.so" | sudo tee -a /etc/opt/rh/rh-php73/php.d/30-redis.ini
-
Verify
redis
PHP module was successfully enabled:php -m | grep redis
-
Restart Apache:
sudo systemctl restart httpd24-httpd
-
(Optional) Remove
rh-php73-php-devel
andrh-php73-php-pear
:sudo yum remove rh-php73-php-devel rh-php73-php-pear
Install Redis on CentOS 7 and RHEL 8 using EPEL/Remi
-
Install Redis and
redis
PHP module:sudo yum install redis php-pecl-redis5
-
Enable and start the Redis service:
sudo systemctl enable --now redis
-
Verify the Redis service is active:
systemctl status redis
-
Verify
redis
PHP module is enabled:php -m | grep redis
-
Restart Apache:
sudo systemctl restart httpd
Enable Redis in API Portal
After you have successfully installed Redis, you must enable it in JAI:
- In the Joomla! Administrator Interface (JAI), click System > Global Configuration > System.
- On the Cache configuration section, set Cache Handler to Redis.
- Review and update the other settings if necessary.
- Click Save.
Additional cache settings in API Portal
To change how long data is preserved in the cache:
- In the JAI, click Components > API Portal > Additional Settings.
- In Cache Timeout, enter how long (in seconds) APIs are preserved in the cache.
- Click Save.
Use the Purge cache button to clear the cache at any time.
Verify Redis installation
To verify that Redis is being used by API Portal, refresh the API Catalog page and enter the following command:
redis-cli keys *_apicatalog
Further Redis configuration
You have learned how to install a basic Redis server, with no authentication or replication. For more advanced configuration, see Redis documentation.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.