mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.23k stars 212 forks source link

Redis cache invalidates unchanged models #385

Closed dalholm closed 3 years ago

dalholm commented 3 years ago

First, thanks for this awesome package. This is more then cool! This is awesome :)

I have developed a product database and have a lot of different product relations and i am using redis as cache. When i am changing a product it seems to invalidate a lot o models. Example.

  1. i go to a category
  2. 276 queries runs first time then just 2 queries
  3. I change a relation to a product that is not in that particular category
  4. Refresh and 243 queries runs first time

is this an expected behavior? or am i missing something?

mikebronner commented 3 years ago

Hi @dalholm, that is expected functionality. The cache will invalidate by model, not be instance, so if once category changes, all categories will be invalidated.

Please feel free to respond, should you have additional questions. Closing for now, as this is expected behavior.