I'd really love to know that too. :) Any tips / articles etc would be appreciated
Maintaining a query cache is fairly simple if you use a cache storage driver supporting tags (like Redis or Memcached).
If you use Eloquent, each model get his own tag (like the class name for example), and on every model saved event, you just flush the cache for that tag.
When storing a query in the cache, you just assign the tag of every model that has influence on the query's output to the cache object. So every time a model gets saved, all related caches get flushed.
You can also create tags for specific models (like Class#id), so you can flush a cache only when a specific model gets changed.
You can append a page number to the cache key to keep paginated caches.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community