Redis cluster PHP client Predis use Example

Source: Internet
Author: User
Tags redis redis cluster

PHP has redis expansion, at present, still do not support Redis cluster, recommended Predis, the function of the whole, from a single, to the master and subordinate, to the cluster are supported. How efficient, you have to rely on their own to test.

1, download Predis

Https://github.com/nrk/predis

2,predis case


<?php

Require ' autoload.php ';

$servers = Array (
' tcp://192.168.10.219:6379 ',
' tcp://192.168.10.219:6380 ',
' tcp://192.168.10.219:6381 ',
' tcp://192.168.10.220:6382 ',
' tcp://192.168.10.220:6383 ',
' tcp://192.168.10.220:6384 ',
);

$options = Array (' cluster ' => ' Redis ');

$client = new Predis\client ($servers, $options);

$client->set ("test", "tank");
$result = $client->get ("test");
Var_dump ($result);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.