Are fetchAll() and for() good choices for my code?
Using fetchAll usually is not a problem. There are some things to optimize here in my opinion:


Use a foreach loop instead of for loop. Your result is already limited. No need to duplicate this here. This removes the iterator counter and assignment:

foreach ($products as $product) {
    $text1 = $product[0];
    $time1 = $product[1];
?&gt;

Using the Object fetch mode (returns objects instead of indexed arrays) makes this even more readable and saves you the name assignments:

foreach ($products as $product) {
     // $product-&gt;text1; $product-&gt;time1;
?&gt;

Though I'd recommend to remove these. Introducing numbers in variable names usually suggests there is a second one. E.g. time2.
As @mat's mug pointed out, indentation is very important. Same goes for empty lines. There are great to structure your code in logical blocks. For this example here, I'd have an empty line after setting up the cache and one after loading the products.