Skip to content

Instantly share code, notes, and snippets.

@sourceperl
Created November 2, 2016 11:57
Show Gist options
  • Save sourceperl/bb417091171731efb1e2f76fd2b1c5b3 to your computer and use it in GitHub Desktop.
Save sourceperl/bb417091171731efb1e2f76fd2b1c5b3 to your computer and use it in GitHub Desktop.
Simple example of Redis usage with PHP
<!DOCTYPE html>
<?php
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
$r = new Predis\Client();
?>
<html>
<head>
<title>Test REDIS</title>
</head>
<body>
<i><u>add Redis PHP lib on debian:</u> sudo apt-get install libphp-predis</i>
<br>
<br>
<b>Redis 'foo' key value:</b> <?php echo $r->get('foo'); ?><br>
<b>Value of 'visit' count:</b> <?php echo $r->incr('visit'); ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment