Torann / laravel-currency

This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.
http://lyften.com/projects/laravel-currency
BSD 2-Clause "Simplified" License
390 stars 137 forks source link

Redis Caching not working #69

Open vigikaran opened 7 years ago

vigikaran commented 7 years ago

i'm using cache driver as redis but it not seems to use cached? my config as follows

'cache_driver' => 'redis',

robbydooo commented 7 years ago

I am having the same problem has anyone managed to fix this?

Each page request is performing a database request with redis as the cache_driver.

robbydooo commented 7 years ago

Actually I have found out what is causing this and its not related to redis it is for all cache drivers.

getCurrencies() in Currency.php has a flag to say if your app is in debug mode then do not cache.

 public function getCurrencies()
    {
        if ($this->currencies_cache === null) {
            if (config('app.debug', false) === true) {
                $this->currencies_cache = $this->getDriver()->all();
            }
            else {
                $this->currencies_cache = $this->cache->rememberForever('torann.currency', function () {
                    return $this->getDriver()->all();
                });
            }
        }

        return $this->currencies_cache;
    }

Is this really needed? Not sure why you wouldnt want cached currencies during development. At least could we have this as a config option so we can override it?