Last active
August 20, 2016 18:46
-
-
Save tillkruss/b2ca21f79a14cd900e4b3b282eaf3447 to your computer and use it in GitHub Desktop.
[WordPress] Redis Test MU-Plugin
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 | |
/* | |
Plugin Name: Redis Test | |
Plugin URI: https://wordpress.org/plugins/redis-cache/ | |
Description: Redis connection test. | |
Author: Till Krüss | |
Version: 1.0 | |
Author URI: https://till.im/ | |
*/ | |
add_filter( 'debug_bar_panels', function ( $panels ) { | |
return array_merge($panels, [new Debug_Bar_Redis_Test]); | |
} ); | |
class Debug_Bar_Redis_Test { | |
function title() { | |
return 'Redis Test'; | |
} | |
function is_visible() { | |
return true; | |
} | |
function prerender() { } | |
function render() { | |
echo '<pre>'; | |
echo 'Deleting test key...' . PHP_EOL; | |
wp_cache_delete( 'redis-test' ); | |
if (! wp_cache_get( 'redis-test' )) { | |
echo 'Test key deleted!' . PHP_EOL; | |
} else { | |
echo 'Test key could not be deleted!' . PHP_EOL; | |
} | |
echo 'Storing test key...' . PHP_EOL; | |
wp_cache_add( 'redis-test', 'foobar' ); | |
echo 'Looking up test key...' . PHP_EOL; | |
if ( wp_cache_get('redis-test') === 'foobar' ) { | |
echo 'Test key found!' . PHP_EOL; | |
} else { | |
echo 'Test key could not be found!' . PHP_EOL; | |
} | |
echo 'Deleting test key...' . PHP_EOL; | |
wp_cache_delete( 'redis-test' ); | |
echo '</pre>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment