Created
May 2, 2018 10:14
-
-
Save foospidy/10b39d0f918f1d7154d314d8334eec55 to your computer and use it in GitHub Desktop.
Example function for incrementing a counter based on the key of $id in Redis.
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 | |
function api_request($id='nobody') { | |
$redis = new Redis(); | |
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) { | |
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) { | |
$redis->incr($id); | |
} else { | |
error_log('Error authenticating to redis!'); | |
} | |
} else { | |
error_log('Error connecting to redis!'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment