Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Why do the cache methods return void?
  • I am curious as to why the cache methods all return void: http://docs.fuelphp.com/classes/cache/usage.html What is the best way to test for a successful / failure action using the the cache methods?
  • In general FuelPHP doesn't use return values to signal state, it uses exceptions. For cache the generic flow is:
    try
    {
        $var = \Cache::get('cache_key');
    }
    catch (\CacheNotFoundException $e)
    {
        // determine the var value
        $var = 'value to cache';
    
        // store it in the case for 60 seconds
        \Cache::set('cache_key', $var, 60);
    }
    
  • Thank you, I found that method useful for setting / checking the cache, but not for making sure a cache was deleted. Delete cache doesnt seem to return anything:
    /**
    * Delete Cache
    */
    public function delete()
    {
    $file = static::$path.$this->identifier_to_path($this->identifier).'.cache';
    @unlink($file);
    $this->reset();
    }
  • Can you create an issue for that on http://github.com/fuel/core/issues, this is not really consistent.
  • Thank you for your suggestion. I am keeping a list of the issues I will need to submit, as well as code improvements I've found. I will submit these all in a batch once I get the first phase of our app launched.

Howdy, Stranger!

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

In this Discussion