make php redis super easy with Redis Cloud
Redis Cloud is a fully-managed cloud service for hosting and running Redis datasets in a highly available and auto-scalable manner, with predictable and stable top performance. It overcomes Redis’ scalability limitation and supports all Redis commands at any dataset size. The service provides in-memory replication and instant auto-failover within the same data center or across data centers. It completely frees developers from dealing with nodes, clusters, scaling, data persistence issues or failure recovery.
Setting up PHP to work with Redis Cloud
Applicable for the Predis client
- Create a new Redis DB at your Redis Labs account.
- Create a new client instance as shown below and enter the following items (provided to you upon DB creation):
- The hostname of your DB's endpoint
- The port number of your DB's endpoint
<?php $redis = new Predis\Client ( 'hostname:port' ); //is equivalent to: $redis = new Predis\Client ( array ( 'scheme' => 'tcp', 'host' => 'hostname', 'port' => port, ) ); //and is also equivalent to: $redis = new Predis\Client ( array ( array ( 'host' => 'hostname', 'port' => port ) ) );
- Note: disable master/slave configuration (write on master, read from slaves). Use the single endpoint provided upon DB creation to access your Redis DB. Redis Cloud distributes your dataset across multiple shards and efficiently balances the load between these shards
- You are done!