Created
March 12, 2020 05:26
-
-
Save naveed125/81a8cdc325b91fa098835008dcf5083d to your computer and use it in GitHub Desktop.
Sample code showing redis INCR command usage
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 | |
// uses Predis | |
// see https://github.com/nrk/predis | |
$client = new Predis\Client(); | |
// connect to the local redis server | |
$client->connect(); | |
// increment the counter in a loop | |
for($i=0;$i<10;$i++) { | |
$id = $client->incr('counter'); | |
echo ("Next user id is:{$id}\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment