Skip to content
Discussion options

You must be logged in to vote

For a larger Laravel application, I’d prefer explicit cache invalidation, but keep it centralized rather than scattering Cache::forget() calls everywhere.

For example, when a Node or Resource changes, invalidate the affected Subject cache from an observer or service:

Cache::forget("subject:{$subjectId}");

I wouldn't rely on cache tags to automatically handle Eloquent relationships—they don't understand your dependency graph.

Also, avoid caching large Eloquent relationship trees unless necessary. Cache expensive query results or computed data where possible.

For more complex/high-churn caches, versioned keys can be useful:

$version = Cache::get("subject:{$id}:version", 1);
$key = "subject:{$…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nasrinlipi41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants