I have a wind captor connected to a dedicated database.
Datas from the captor are pushed to the db every minutes.
I have no problem to connect to the second db and print the data to a wp page using
$meteodb = new wpdb('xx','xx','xx','xx'); $meteoValues = $meteodb->get_results( " SELECT average, min, max, direction, timestamp FROM wind ORDER BY timestamp " );
I am totaly new to transient concept. I try to be efficient wise using db requests to the minimum
Instead of connecting directly to the second database everytime a user view the page, I thought it might be a good idea to create a transient says every 5 min pulling new set of datas from second database directly to wp database using a cron. I would keep only the datas from the current day (from 6am to 8pm) and have them auto wiped after 24 hrs
Do you think it is a wise idea?
would it be smarter to have 1° a new transient recorded every 5 min with only the new data and then call all the transient that are available (less than 24 hrs)
2° a single transient refreshed every 5 min with an array containing all the datas from the last 24 hrs?
with a validity of 5 min only (or even 2 minutes), does that sounds smart to use transient?
Thank you in advance