Why WordPress creates two transients: Because the first transient with timeout
in the name, is used for storing the expiration you set for your transient (but the stored value is a UNIX timestamp, not simply the value you passed like 3600
) so that WordPress knows when to delete your transient. As for the second one, it stores the actual transient value that you passed to set_transient()
, i.e. the second parameter.
$key = 'mytransientprefix_key';
set_transient( $key, 'value', 3600 );
// That will create two options:
// _transient_timeout_mytransientprefix_key and
// _transient_mytransientprefix_key
var_dump(
get_option( '_transient_timeout_' . $key ),
get_option( '_transient_' . $key )
);
// Sample output: int(1611143902) string(5) "value"
So the value of the “timeout” transient shouldn’t be value
— try the above code and see how it goes?