JoneSolutions
Sign in

How to use Redis?

Redis - A persistent object cache backend, will speed up the query or access of your site when using the database. Aside from this, we are now using Redis for the PHP sessions handler because running PHP sessions via files is very slow aside from eating disk space. If you have session.save_handler enabled on your PHP script, make sure to disable it but most PHP sites do not enable it so you should be fine.

If you are using WordPress, Drupal, Joomla, or Magento, below are some of our recommendations so you can use the object cache backend by Redis:

For Wordpress, please log in to your WP-Admin and install the plugin Redis. The author is https://wordpress.org/plugins/redis-cache/ , activate it then go to the settings and click Redis to make sure the cache is enabled.

( This is not needed but make sure to check your wp-config.php that it is there )
Then, edit your wp-config.php and add the following under * Authentication Unique Keys and Salts :

define('WP_CACHE_KEY_SALT', 'yourdomain.com');
define('WP_CACHE', true);

Change yourdomain.com with your domain of course then save the file. That's it!


-----------------------------------------------------------

For Joomla, log in to your administrator account, go to Global Configuration, system then you will see Cache Settings then change the cache handler to Redis and leave the rest as is then under Session Settings, change session handler to Redis and leave as is then save. That's it!

------------------------------------------------------------------------

For Magento, edit app/etc/env.php and before 'install'=>array , add the following:

'cache' => array(
'frontend' => array(
'default' => array(
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => array(
'server' => '127.0.0.1',
'database' => '0',
'port' => '6379'
),
),
'page_cache' => array(
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => array(
'server' => '127.0.0.1',
'port' => '6379',
'database' => '1',
'compress_data' => '0'
)
)
)
),
'session' => array(
'save' => 'redis',
'redis' => array(
'host' => 'localhost',
'port' => '6379',
'password' => '',
'timeout' => '2.5',
'persistent_identifier' => '',
'database' => '2',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '6',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '0',
'min_lifetime' => '60',
'max_lifetime' => '2592000',
),
),

That's it!

------------------------------------------------------------------------------------

For Drupal, edit your settings.php and add or replace memcached with the following:

// Redis settings
$conf['redis_client_interface'] = 'PhpRedis';
$conf['redis_client_host'] = '127.0.0.1';
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_default_class'] = 'Redis_Cache';
// For multisite, you must use a unique prefix for each site
$conf['cache_prefix'] = 'site1';

Make sure to change site1 with your domain name.

That's it!


Please note that the above configurations are based on the latest php scripts as of this writing.

We are now using Mod_lsapi ( litespeed technology ), OPCache and Redis.


If you have any questions, please do not hesitate to contact tech@jonesolutions.com .

Was this article helpful?