-
Gebruik de Predis-bibliotheek.
-
Maak verbinding met Redis ElastiCache Endpoint in Cluster-modus met behulp van Predis, zie onderstaand voorbeeld.
try{ // Put your AWS ElastiCache Configuration Endpoint here. $servers = ['aliceredis.8xyzwu.clustercfg.euw2.cache.amazonaws.com:6379']; // Tell client to use 'cluster' mode. $options = ['cluster' => 'redis']; // Create your redis client $redis = new Predis\Client($servers, $options); // Do something you want: // Set the expiration for 7 seconds $redis->set("tm", "I have data for 7s."); $redis->expire("tm", 7); $ttl = $redis->ttl("tm"); // will be 7 seconds // Print out value of the key 'tm' var_dump(array("msg"=>"Successfully connected to Redis Cluster.", "val"=>$redis->get("tm"))) ; } catch(Exception $ex){ echo ('Error: ' . $ex->getMessage() ); // output error message. }