mikebronner/laravel-model-caching

Exclude specific models when caching is enabled in BaseModel

sburkett opened this issue · 3 comments

Somewhat self-explanatory, but in short, we have hundreds of models in play. We are currently the BaseModel/use Cachable; approach. It works great! However, there are a handful of models that we don't want to cache. Instead of having to remove the caching trait from the BaseModel and having to add it into hundreds of models, it would be great if we could somehow exclude certain models from being cached.

Could be via some other trait (use NotCacheable) or perhaps an exclusionary array of model names in the config file. Thoughts?

Hi @sburkett, thanks for writing in! I believe you should be able to add the following protected property on those models:

protected $isCachable = false;

Let me know how that works for you.

Works like a champ! Thanks!

That's awesome :)