transient or not transient

Transients are a simple way of storing cached data in the database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted. So yes, it will be a good idea to get data from second DB and store it as a transient.

First thing you have to remember is that:

Everyone seems to misunderstand how transient expiration works, so the
long and short of it is: transient expiration times are a maximum
time. There is no minimum age. Transients might disappear one second
after you set them, or 24 hours, but they will never be around after
the expiration time.

And of course it will be pretty hard to select all transients from last 24 hours by your name – names of transients are suffixed with random values (or maybe hashes – it’s not important in this case).

Given these two facts, I’m afraid both your methods won’t work.

There is no point in setting transients with cron – they may disappear right after that. And you can’t store values from last 24 hours and select all of them from DB.

So how would I use transients in this case?

Let’s say there is a function that grabs all data from second DB as an array. Let’s call this function get_remote_db_data(). My code would look something like this:

$data = get_transient('my_transient_name');
if ( ! $data ) {
    $data = get_remote_db_data();
    set_transient('my_transient_name', $data, 5*60);
}
// ... do your stuff with $data

And how long the expiration time should be? It depends on how frequently should the data be refreshed.