Skip to content

Instantly share code, notes, and snippets.

@naveed125
Created March 12, 2020 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naveed125/81a8cdc325b91fa098835008dcf5083d to your computer and use it in GitHub Desktop.
Save naveed125/81a8cdc325b91fa098835008dcf5083d to your computer and use it in GitHub Desktop.
Sample code showing redis INCR command usage
<?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