Skip to content

Instantly share code, notes, and snippets.

@makgithub
Created July 18, 2017 13:43
Show Gist options
  • Save makgithub/cc662954d991ad19e743df3933578c4c to your computer and use it in GitHub Desktop.
Save makgithub/cc662954d991ad19e743df3933578c4c to your computer and use it in GitHub Desktop.
Getting Started with Redis in PHP
<?php
//echo phpinfo();exit;
//Connecting to Redis server on localhost
$redis = new Redis();
$status=$redis->connect('XXX.XXXX.XXX.XXX', $portnumber);
echo "<pre>";
echo "Connection to server sucessfully";
//check whether server is running or not
echo "Server is running: ".$redis->ping();
//creating the key
$key="Key_Name";
$redis->set($key, 'MAK Key Venki');
//Retreving the specified key value
echo $redis->get($key);
// Get the stored keys and print it
$arList = $redis->keys("*");
echo "Stored keys in redis:: " ;
print_r($arList);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment