tencent cloud

TencentDB for Tendis

Release Notes
Product Introduction
Overview
Strengths
Use Cases
Product Series
Performance
Command Compatibility
Regions and AZs
Relevant Concepts
Relevant Products
Purchase Guide
Billing Overview
Pricing
Payment Overdue Policy
Getting Started
Creating Tendis Instances
Connecting to Tendis Instances
iptables Forwarding
Operation Guide
Instance Connection Using Programming Languages
Instance Maintenance and Management
Monitoring Features
Configuring Security Groups
Disabling Commands
FAQs
General
Purchase
Connection and Login
Contact Us
Tendis Policy
Privacy Policy
Data Privacy and Security Agreement
Glossary

PHP Connection Sample

PDF
Focus Mode
Font Size
Last updated: 2023-12-21 21:11:22
Preparations before running: Download the phpredis client.
Sample code:
<?php
/**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) {
die($redis->getLastError());
}
// Authenticate
if ($redis->auth($pwd) == false) {
die($redis->getLastError());
}

/**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) {
die($redis->getLastError());
}
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:


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback