tencent cloud


PHP Connection Sample

Last updated: 2021-01-15 16:35:29

Preparations before running:
Download the phpredis client.

Sample code:

  /**Enter your Tendis instance private IP, port number, instance ID, and password in the following parameters*/
  $host = "192.xx.xx.2";
  $port = 6379;
  $pwd = "123tj6na";

  $redis = new Redis();
  // Connect to the Tendis instance
  if ($redis->connect($host, $port) == false) {
  // Authenticate
  if ($redis->auth($pwd) == false) {

  /**You can start manipulating the Tendis instance. For more information, please visit https://github.com/phpredis/phpredis. */

  // Set the key
  if ($redis->set("redis", "tencent") == false) {
  echo "set key redis suc, value is:tencent\n";

  // Get the key
  $value = $redis->get("redis");
  echo "get key redis is:".$value."\n";

Execution results:

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support