Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Checking Cache exists?
  • From my understanding, the Cache class provided by FuelPHP is a wrapper over the configured (selected) caching library.

    What I see from documentation available for me is Cache::get() will throw an CacheNotFoundException if cache does not exists, but throwing and catching exception sounds heavy operation for me (generating stack traces etc).

    Is there another way to check the cache not exists?
    i.e. Memcached have a getResultCode() method...

  • HarroHarro
    Accepted Answer
    No, there isn't.

    This is a much debated issue, and up until now we haven't found a satisfactory solution, one that doesn't require complete redesign. The problem with static methods is that you have no object to work with, so there is also no object to call a getResultCode() on.

    So this requires, like we've done for many other classes in recent times, refactoring in which the static facade will be split from the cache instance (for example Crypt, Session and Asset already work that way).

    Since you don't tend to cache lots of things at once, and the reason you cache is so that you don't have a lot of "not found"'s, it hasn't had a very high priority up until now.
  • Thanks Harro! 
    Then maybe I should build my own Cache provider (wrap over the Memcached) to manage my own cache objects instead? 
    Because the caches will purely be result of my orm query objects.
  • If you feel that gives you additional performance, who am I to stop you from doing that?

Howdy, Stranger!

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

In this Discussion