Created
July 18, 2017 13:43
-
-
Save makgithub/cc662954d991ad19e743df3933578c4c to your computer and use it in GitHub Desktop.
Getting Started with Redis in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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