PowerGrid Caching Not Working with Laravel Livewire Listing
Closed this issue · 2 comments
Have you searched through other issues to see if your problem is already reported or has been fixed?
Yes, I did not find it.
Did you read the documentation?
Yes, I did not find it.
Have you tried to publish the views?
Yes - I didn't work.
Is there an error in the console?
No
PHP Version
8.2
PowerGrid
6.0
Laravel
11.9
Livewire
3.5
Alpine JS
No response
Theme
Bootstrap
Describe the bug.
I'm working on a Laravel Livewire project where we are using PowerGrid for our data tables. I've recently upgraded to the latest version of PowerGrid, which supports default caching. Following the documentation steps, I have configured caching as described, but I'm not seeing the expected behavior—data is not being stored in the cache.
Cache Driver: I’ve set the cache driver to file.
Setup: I have enabled caching for the module as mentioned in the documentation and included the cache() method from the LivewirePowerGrid\Cache class in the component's setup() method.
To Reproduce...
Steps to Reproduce:
Set up the caching in the component as per the documentation.
Enable the file cache driver in the config/cache.php file.
Load the data table in the Livewire component.
Expected Behavior:
The data should be cached and stored in the specified cache driver.
Actual Behavior:
The caching is not working as expected, and no data is being stored in the cache.
Extra information
<?php
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;
public function setUp(): array
{
// $this->showCheckBox();
$cache = PowerGrid::cache()->prefix('user_');
return [
PowerGrid::header()
->showSearchInput(),
PowerGrid::footer()
->showPerPage()
->showRecordCount(),
PowerGrid::cache()
->customTag('users'),
];
}
I have confirmed that the cache driver is correctly set up and that other parts of my application successfully use the file cache driver.
No error messages or exceptions are being thrown in the logs.
Hello.
You need to add ttl()
to set the cache lifetime
Hello @luanfreitasdev ,
I have tried adding ttl()
also to the setup method, but it didn't work.