hi together
im on a caching task and im not sure i use it properly. maybe you guys have an idea. i have a big sql lite table (200’000 entries) and im want caching results from this. im using the basic api cache pattern like this.
i got an array back with all demanded rows. because im using the result to fetch DB entries i have to convert the array back to an proper kirby object.
$prepData = new Obj($apiCache['data']);
and later in the loop each item
foreach ($prepData as $item) {
$item = new Obj($item);
echo $item->entry_id()
...
}
after this, the cache is working properly and i can access all items like $item->entry_id() in the loop.
now, my questions:
it this a proper way to cache DB rows?
DB:select return in the basic usage a prepared kirby collection, and all items are class Obj. Is there a better way to convert the array in my workflow?
Is there any example how to use this? I can’t figure out:
$apiDataTrendQuery = Db::query(
'SELECT title,text
FROM y_entry
INNER JOIN y_user
ON y_entry.entry_sender == y_user.id
WHERE y_user.active == "1"
ORDER BY y_entry.entry_creationDate DESC
LIMIT 100'
);
SQL is fine, i get all data, but as Objects. I can use ->toArray() to convert the Collection. But how i can use fetch() in this case?