Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Disable orm cache global
  • Is there a way to globally disable the orm cache? Maybe a config item?
  • No, there is not.

    As of 1.6, you can disable the cache on per-query basis, using array('from_cache' => false) on a find(), or from_cache(false) on a query().

    It will not have any impact on memory usage (hydration and object creation happens anyway, otherwise there's nothing to return), and will cause queries to be slower if you fetch the same record a second time.
  • Okay, thanks! I'll rewrite some stuff then ;-)

    When does caching happen btw? Only with find() or also with $query = Model_Article::query()->where('category_id', 1)->order_by('date', 'desc'); ?
  • Caching happens during hydration. So on every query fired.

    Caching is done on primary key. When a primary key is detected in the result, and an object with that key is already in cache, hydration doesn't happen, but the object from cache is used.
  • Ok thanks! So if I want to edit or add a new record, orm is good/fast to use (with find()). If i want to select a large amount of records (say 10000). Best way to go is to use the query builder?
  • Correct. You should not use the ORM for bulk operations, it will never be fast or efficient.

Howdy, Stranger!

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

In this Discussion