Skip to content

Instantly share code, notes, and snippets.

@jgauthi
Forked from raphaelstolt/redis-glue-test.php
Last active June 23, 2021 13:25
Show Gist options
  • Save jgauthi/472201bc7e7a5cb55a90f9e6a2bf35a9 to your computer and use it in GitHub Desktop.
Save jgauthi/472201bc7e7a5cb55a90f9e6a2bf35a9 to your computer and use it in GitHub Desktop.
Redis installation test script
<?php
const TEST_KEY = 'are_we_glued';
const REDIS_HOST = 'localhost';
const REDIS_PORT = 6379;
$redis = new Redis;
try {
$redis->connect(REDIS_HOST, REDIS_PORT);
$redis->set(TEST_KEY, 'yes');
$glueStatus = $redis->get(TEST_KEY);
if ($glueStatus) {
$testKey = TEST_KEY;
echo 'Glued with the Redis key value store:'.PHP_EOL;
echo "1. Got value '{$glueStatus}' for key '{$testKey}'.".PHP_EOL;
if ($redis->del(TEST_KEY)) {
echo '2. And already removed the key/value pair again.'.PHP_EOL;
}
} else {
echo 'Not glued with the Redis key value store.'.PHP_EOL;
}
} catch (RedisException $e) {
$exceptionMessage = $e->getMessage();
echo "{$exceptionMessage}. Not glued with the Redis key value store.".PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment