F
Filament15mo ago
Vp

cache with table query

I want to create cache for table builder, but the ->query() expect query builder, not eloquent, how can I create cache
public function table(Table $table): Table
{
return $table
->query(
// not working
// Cache::remember('users', 60 * 60 * 24, function () {
// return User::query();
// })
User::query() // working
);
}
public function table(Table $table): Table
{
return $table
->query(
// not working
// Cache::remember('users', 60 * 60 * 24, function () {
// return User::query();
// })
User::query() // working
);
}
User::get() inside cache is working, but table expect query..
Solution:
I don't think you can till eloquent call the get() it won't execute the query and then nothing to cache...
Jump to solution
4 Replies
Solution
Lara Zeus
Lara Zeus15mo ago
I don't think you can till eloquent call the get() it won't execute the query and then nothing to cache
Vp
VpOP15mo ago
Yes correct, do you know an alternative ways or does it need here, Because I want to display data that will change 1-2 times a year only that's why I try cache for performance
Lara Zeus
Lara Zeus15mo ago
do you have much traffic to that page? I won't worry about that and keep it as it I think it is hard to cache it since filament will also add wheres for filters and sorting and searching
Vp
VpOP15mo ago
OK, then I'll leave it as it is.. thanks for heads up
Want results from more Discord servers?
Add your server