Why are transients cleared prematurely?

You would think that a transient set to expire at a certain time, would exist until that time. Unfortunately it seems they are disappearing from the database earlier, both on test and production. As a simple example to see this behavior, try: <?php /* Plugin Name: Test transient Description: Show transients bug Version: 0.1 */ … Read more

Best practices for using the transients API

I’ve recently come across the Transients API in WordPress in hopes of improving the performance of the plugin that I’m trying to write. Basically the plugin is storing product details from the amazon product advertising API in the database. The product details are stored using the json encoded representation of the array. Now I’m trying … Read more

Is get_option() faster than accessing get_transient()?

Today I run a test over my db to explore the speed difference between accessing a key from options, custom table & transients. I ran the test for 1000 times and following is the time taken to run 1000 get operations: get_transient() 0.0245 seconds get_option() 0.0068 seconds simple select operation from Custom Table 0.65 seconds … Read more

How to make sure that only one wp_cron() runs at a time?

I have around 20 wp_cron() functions like the following code. Almost all crons run hourly; a few are daily. if ( ! wp_next_scheduled( ‘my_task_hook’ ) ) { wp_schedule_event( time(), ‘hourly’, ‘my_task_hook’ ); } add_action( ‘my_task_hook’, ‘my_task_function’ ); function my_task_function() { //Complex Code } To increase server performance, and so as not to keep getting server … Read more