Demian Swift
Demian Swift

Reputation: 21

Call to undefined method Illuminate\Cache\FileStore::lock() when trying to use session blocking in Laravel 7

I`ve been upgrading from Laravel 6 to Laravel 7 without any problems. My goal was to use the session blocking feature introduced from Laravel 7.10. My current Laravel version is 7.28.

After I chain the block method on my routes I get the following error: Call to undefined method Illuminate\Cache\FileStore::lock() after trying to execute any of the routes.

I`ve changed mysession driver from file to database as the file driver cannot be used for the session blocking. Everything seems to be working fine. The session goes into the database.

This is my route

Route::get('add-to-cart/{product}', 'ProductController@addToCart')->name('product.addToCart')->block($lockSeconds = 10, $waitSeconds = 10);

This is where the stack trace error occurs

C:\Projects\KH_WORK\AppleFix\vendor\laravel\framework\src\Illuminate\Cache\Repository.php:646

This is the error

Call to undefined method Illuminate\Cache\FileStore::lock()

After some digging I think that Laravel should be trying to call Illuminate\Cache\DatabaseStore class and not Illuminate\Cache\FileStore class as the sesssion block functionality cannot be used with file session driver. Also the DatabaseStore class has a lock method. I did php artisan config:clear, php artisan cache:clear and composer dump-autoload but its still calling FileStore...

Any help will be appreciated.

Upvotes: 0

Views: 5663

Answers (1)

Demian Swift
Demian Swift

Reputation: 21

Pardon me... I`m an idiot. To use the session block functionality my "cache" driver should be database, not my session driver. Case closed.

Upvotes: 0

Related Questions