bb_set_transient

Set/update the value of a transient.

Description

bb_set_transient( (string) $transient, (mixed) $value, (int) $expiration = 0 ); 

You do not need to serialize values, if the value needs to be serialize, then it will be serialized before it is set.

Parameters (3)

0. $transient (string)
Transient name. Expected to not be SQL-escaped
1. $value (mixed)
Transient value.
2. $expiration — Optional. (int)
Time until expiration in seconds, default 0

Usage

  1. if ( !function_exists( 'bb_set_transient' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-meta.php'; 
  3.  
  4. // Transient name. Expected to not be SQL-escaped 
  5. $transient = ''; 
  6.  
  7. // Transient value. 
  8. $value = null; 
  9.  
  10. // Time until expiration in seconds, default 0 
  11. $expiration = -1; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_set_transient($transient, $value, $expiration); 
  15.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-meta.php  
  1. function bb_set_transient( $transient, $value, $expiration = 0 ) 
  2. global $_bb_using_ext_object_cache, $bbdb; 
  3.  
  4. if ( $_bb_using_ext_object_cache ) { 
  5. return wp_cache_set( $transient, $value, 'transient', $expiration ); 
  6. } else { 
  7. $transient_timeout = '_transient_timeout_' . $bbdb->escape( $transient ); 
  8. $transient = '_transient_' . $bbdb->escape( $transient ); 
  9. if ( 0 != $expiration ) { 
  10. bb_update_option( $transient_timeout, time() + $expiration ); 
  11. return bb_update_option( $transient, $value );