Created
April 10, 2012 15:50
-
-
Save tollmanz/2352340 to your computer and use it in GitHub Desktop.
Another locking technique that should only allow one execution per hour
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 test_race() { | |
$key = date( 'YdmH', time() ); | |
wp_cache_add( $key, 0 ); | |
if ( 1 !== wp_cache_incr( $key ) ) | |
return false; | |
// Do the things | |
} | |
add_action( 'init', 'test_race' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment