Skip to content

Instantly share code, notes, and snippets.

@tollmanz
Created March 12, 2012 18:13
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 tollmanz/2023731 to your computer and use it in GitHub Desktop.
Save tollmanz/2023731 to your computer and use it in GitHub Desktop.
Return values for memcache in WordPress
<?php
add_action( 'init', 'test' );
function test() {
// Returns bool( false )
set_transient( 'test-trans-false', false, 5 );
get_transient( 'test-trans-false' );
// Return bool( false )
set_transient( 'test-trans-true', true, 5 );
get_transient( 'test-trans-true' );
// Return bool( false )
set_transient( 'test-trans-0', 0, 5 );
get_transient( 'test-trans-0' );
// Return int( 1 )
set_transient( 'test-trans-1', 1, 5 );
get_transient( 'test-trans-1' );
// Return string( 'no' )
set_transient( 'test-trans-no', 'no', 5 );
get_transient( 'test-trans-no' );
// Return string( 'yes' )
set_transient( 'test-trans-yes', 'yes', 5 );
get_transient( 'test-trans-yes' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment