Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:cache:lscwp:configuration:cache:object_cache [2018/01/26 16:47]
Jackson Zhang [Memcached and Redis (Object Cache) Support in LSCWP]
litespeed_wiki:cache:lscwp:configuration:cache:object_cache [2020/05/04 13:55] (current)
Shivam Saluja
Line 1: Line 1:
 ====== Memcached, LSMCD and Redis (Object Cache) Support in LSCWP ====== ====== Memcached, LSMCD and Redis (Object Cache) Support in LSCWP ======
 +**Please Note**: This wiki is valid for v2.9.x and below of the LiteSpeed Cache Plugin for WordPress. If you are using v3.0 or above, please see [[https://​docs.litespeedtech.com/​lscache/​lscwp/​overview/​|the new documentation]].
  
 As of version 1.8, LiteSpeed Cache for WordPress supports Object Cache. As of version 1.8, LiteSpeed Cache for WordPress supports Object Cache.
Line 17: Line 18:
 LSCWP doesn'​t provide object caching directly. Rather, it supports your use of an external object cache such as [[http://​memcached.org/​about|Memcached]] or LiteSpeed'​s drop-in Memcached replacement,​ [[https://​www.litespeedtech.com/​open-source/​litespeed-memcached|LSMCD]]. LSCWP doesn'​t provide object caching directly. Rather, it supports your use of an external object cache such as [[http://​memcached.org/​about|Memcached]] or LiteSpeed'​s drop-in Memcached replacement,​ [[https://​www.litespeedtech.com/​open-source/​litespeed-memcached|LSMCD]].
  
-**Further Reading** +==== Install Memcached, LSCMD or Redis and PHP Extension ==== 
-  * [[:install_memcached|Installing Memcached or LSMCD]]+ 
 +You will need a working and fully tested installation of Redis, Memcached, or LSMCD, as well as the related PHP extension (i.e. php-memcached or php-redis) in order to make your object cache work properly with WordPress. 
 + 
 +Installation of the above software is outside of the scope of this wiki, but we have other wikis that may help: 
 +  * [[litespeed_wiki:lsmcd:​install-memcached|Installing Memcached or LSMCD and php-memcached]] 
 +  * [[litespeed_wiki:​cache:​redis|Integrate Redis with WordPress through LSCWP]]
   * [[litespeed_wiki:​cache:​lscwp:​configuration:​cache:​object_cache:​unix-socket|Using Memcached in a UNIX Socket]]   * [[litespeed_wiki:​cache:​lscwp:​configuration:​cache:​object_cache:​unix-socket|Using Memcached in a UNIX Socket]]
-  * [[:redis_unix_socket|Using Redis in a UNIX Socket]]+  * [[litespeed_wiki:cache:​lscwp:​configuration:​cache:​object_cache:​redis-unix-socket|Using Redis in a UNIX Socket]] 
 + 
 +==== Config Object Cache in LSCWP ====
  
-If you are using LSMCD or Memcached, you can set up LSCWP support in the Cache Settings tab. Navigate to **LiteSpeed Cache > Settings > Cache** and scroll down to **Object Cache**. You will need to give LSCWP some parameters, including where your Memcached or LSMCD lives, which objects you'd like to have cached, and how long you want objects to remain in cache, among other things.+If you are using LSMCDMemcached ​or Redis, you can set up LSCWP support in the Cache Settings tab. Navigate to **LiteSpeed Cache > Settings > Advanced** and scroll down to **Object Cache**. You will need to give LSCWP some parameters, including where your Memcached or LSMCD lives, which objects you'd like to have cached, and how long you want objects to remain in cache, among other things.
  
 Before enabling Object Cache, the default values with already be filled in for you, like so:  Before enabling Object Cache, the default values with already be filled in for you, like so: 
Line 28: Line 36:
 {{:​litespeed_wiki:​cache:​lscwp:​configuration:​cache:​disableobject.png?​600|}} {{:​litespeed_wiki:​cache:​lscwp:​configuration:​cache:​disableobject.png?​600|}}
  
-After enabling Object Cache, the LSCache plugin will automatically run both connection testing and Memcached extension detection.+After enabling Object Cache, the LSCache plugin will automatically run both connection testing and Memcached/​Redis ​extension detection.
  
 {{:​litespeed_wiki:​cache:​lscwp:​configuration:​cache:​enabledobject.png?​600|}} {{:​litespeed_wiki:​cache:​lscwp:​configuration:​cache:​enabledobject.png?​600|}}
  
-Detailed instructions for all of these settings can be found [[litespeed_wiki:​cache:​lscwp:​configuration:​cache#​object_cache|here]].+Detailed instructions for all of these settings can be found [[litespeed_wiki:​cache:​lscwp:​configuration:​advanced#​object_cache|here]].
  
 ===== How to Verify===== ===== How to Verify=====
Line 60: Line 68:
   - Try ''​ss -lptun | grep 11211'',​ to make sure the Memcached port is listening.   - Try ''​ss -lptun | grep 11211'',​ to make sure the Memcached port is listening.
   - Try ''​telnet localhost 11211'',​ to make sure you can connect to localhost successfully.   - Try ''​telnet localhost 11211'',​ to make sure you can connect to localhost successfully.
 +
 +
 +===== Test files =====
 +
 +You can create test PHP files to test connection
 +
 +For Memcached:
 +
 +<​code>​
 +<?php
 +
 +$conn = new Memcached ;
 +$address = '/​path/​to/​memcached.sock'​ ; // set the address here
 +$port = 0 ;                            // set the port
 +$conn->​addServer( ​ $address, $port ) ;
 +var_dump( $address ) ;
 +var_dump( $port ) ;
 +var_dump( $conn->​getStats() ) ;
 +echo '<​hr>';​
 +var_dump($conn->​getServerList());​
 +?>
 +</​code>​
 +
 +For redis:
 +
 +<​code>​
 +<?php
 +
 +$cfg_host = 'redis address'​ ;
 +$cfg_port = '​6379'​ ; // or 0 if use socket
 +$cfg_pswd = ''​ ; // Set if has
 +$cfg_db = 0 ;
 +
 +
 +$conn = new Redis() ;
 +$conn->​connect( $cfg_host, $cfg_port ) ;
 +if ( $cfg_pswd ) $conn->​auth( $cfg_pswd ) ;
 +if ( $cfg_db ) $conn->​select( $cfg_db ) ;
 +
 +var_dump( $conn->​ping() ) ; // Should give a `+PONG`
 +?>
 +</​code>​
  
  • Admin
  • Last modified: 2018/01/26 16:47
  • by Jackson Zhang