laravel-geoip
laravel-geoip copied to clipboard
This cache store does not support tagging.
src/Cache.php 32 row add code
if (strstr(config('cache.default'), 'file') || strstr(config('cache.default'), 'database')) {
config(['cache.default' => 'array']);
}
I'm getting this too. Using redis as a cache driver... @Torann any fixes for that?
I ended up setting 'cache_tags' as an empty array in geoip.php
config file
/*
|--------------------------------------------------------------------------
| Cache Tags
|--------------------------------------------------------------------------
|
| Cache tags are not supported when using the file or database cache
| drivers in Laravel. This is done so that only locations can be cleared.
|
*/
'cache_tags' => [],
What version of Laravel are you using?
@Torann I'm using LV 5.8
It sounds like you are trying to use caching with GeoIP, but the caching driver you have set as the default for the application doesn't support tagging, which is a requirement for caching to work with GeoIP. I would suggest turning off caching for GeoIP, 'cache' => 'none'
and see if that solves it.
@Torann setting 'cache_tags' => []
insead of 'cache_tags' => ['torann-geoip-location']
in the config file solved the issue. But does that mean it is still caching? As you know caching is essential.
On a side note, the object returned does not contain cached
It is not caching. Doing 'cache_tags' => []
is also turning off caching. The error message This cache store does not support tagging
is telling you that your application setup for caching does not support tagging, which is required by GeoIP. So in this case you need to disable caching for GeoIP or setup caching for the application that supports tagging. This is explained some in the config file https://github.com/Torann/laravel-geoip/blob/master/config/geoip.php#L122
Another quick is to change CACHE_DRIVER in .env to CACHE_DRIVER=array
Another quick change in geoip.php
:
'cache_tags' => env('CACHE_DRIVER', 'array') === "file" ? [] : ['torann-geoip-location'],
@Torann I set cache to 'none' and it still attempts to initialize the Cache object, throwing the BadMethodCallException.
I think there should be another check like if ($this->config('cache', 'none') !== 'none') ...
around src/GeoIP.php line 88.
Thanks for putting out this package!
If anyone is interested in a quick fix for this issue, I use file for local dev and use redis for production/staging. Here is some code I added to the geoip config file
'cache_tags' => (
strtolower(config('cache.default')) === 'file'
|| strtolower(config('cache.default')) === 'database'
) ? [] : [
'torann-geoip-location'
],
I would recommend just turning off caching on your local, or if you're using Homestead just use the Redis built into it. It's better to mirror your production env when developing locally, less likely to run into one offs like this :-)
I would recommend just turning off caching on your local, or if you're using Homestead just use the Redis built into it. It's better to mirror your production env when developing locally, less likely to run into one offs like this :-)
'cache_tags' => in_array(config('cache.default'), ['array', 'redis'])
? ['torann-geoip-location']
: null,