Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Cache by environment
  • Is there a way to get Cache::get() to throw CacheNotFoundException depending on the environment? I'm trying to make it so the cache only runs when in production and I'm ending up writing code like this. Or is there maybe a better way to go about this?
    try {
     $value = Cache::get('something');
     if (Fuel::$env !== Fuel::PRODUCTION) {
      throw new CacheNotFoundException;
     }
    } catch (CacheNotFoundException $e) {
        ...
    }
    

    Thanks!
  • Extend the cache class, overload the get method, and do your environment check there? Then it will be transparent for your app code.
  • That's a good idea, thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion