| @@ -353,8 +353,16 @@ | ||
| 353 | 353 | ct_reset_setup_table(); |
| 354 | 354 | return $cache; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | + $cache = get_transient( 'automatorwp_triggers_in_use' ); | |
| 358 | + | |
| 359 | + // If result is in a transient, return it | |
| 360 | + if( is_array( $cache ) && count( $cache ) ) { | |
| 361 | + ct_reset_setup_table(); | |
| 362 | + return $cache; | |
| 363 | + } | |
| 364 | + | |
| 357 | 365 | $triggers_in_use = array(); |
| 358 | 366 | $results = $wpdb->get_results( "SELECT t.type FROM {$ct_table->db->table_name} AS t GROUP BY t.type" ); |
| 359 | 367 | |
| 360 | 368 | ct_reset_setup_table(); |
| @@ -364,8 +372,11 @@ | ||
| 364 | 372 | } |
| 365 | 373 | |
| 366 | 374 | // Cache function result |
| 367 | 375 | automatorwp_set_cache( 'triggers_in_use', $triggers_in_use ); |
| 376 | + | |
| 377 | + // Store the result for a day | |
| 378 | + set_transient( 'automatorwp_triggers_in_use', $triggers_in_use, HOUR_IN_SECONDS * 24 ); | |
| 368 | 379 | |
| 369 | 380 | return $triggers_in_use; |
| 370 | 381 | |
| 371 | 382 | } |