Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This cache store does not support tagging. #147

Open
hongyukeji opened this issue Aug 13, 2019 · 14 comments
Open

This cache store does not support tagging. #147

hongyukeji opened this issue Aug 13, 2019 · 14 comments

Comments

@hongyukeji
Copy link

src/Cache.php 32 row add code

if (strstr(config('cache.default'), 'file') || strstr(config('cache.default'), 'database')) {
    config(['cache.default' => 'array']);
}
@radwanic
Copy link

radwanic commented Sep 5, 2019

I'm getting this too. Using redis as a cache driver... @Torann any fixes for that?

@radwanic
Copy link

radwanic commented Sep 5, 2019

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' => [],

@Torann
Copy link
Owner

Torann commented Sep 5, 2019

What version of Laravel are you using?

@radwanic
Copy link

radwanic commented Sep 5, 2019

@Torann I'm using LV 5.8

@Torann
Copy link
Owner

Torann commented Sep 5, 2019

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.

@radwanic
Copy link

radwanic commented Sep 5, 2019

@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

image

@Torann
Copy link
Owner

Torann commented Sep 5, 2019

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

@djunehor
Copy link

Another quick is to change CACHE_DRIVER in .env to CACHE_DRIVER=array

@Shipu
Copy link

Shipu commented Jan 8, 2020

Another quick change in geoip.php:

'cache_tags' => env('CACHE_DRIVER', 'array') === "file" ? [] : ['torann-geoip-location'],

@chuck-wood
Copy link

chuck-wood commented Aug 11, 2020

@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!

@KieronWiltshire
Copy link

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'
    ],

@Torann
Copy link
Owner

Torann commented Feb 8, 2021

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 :-)

@a-vasyukov
Copy link

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,

@mostafiz80
Copy link

Which solution i should use. i am confused littlebit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants