Add 404 cache to TagFactoryImpl
We have a lot of places in code where content with a tag field but no tags will churn the db. If the db query comes up empty, we need to store an empty value there and check against it before hitting the db
https://github.com/dotCMS/core/blob/master-3.5/src/com/dotmarketing/tag/business/TagFactoryImpl.java#L179
https://github.com/dotCMS/core/blob/master-3.5/src/com/dotmarketing/tag/business/TagFactoryImpl.java#L593
.... Please look at all methods that call the cache and DB
@wezell, I have been running, debugging and studying this code today, also I met with @jgambarios (he did this tag refactor) to talk about your request. We have some concerns that I will try to expose here:
- We don't have clear where this code could churn the DB. For example, all of the calls to getTagByTagId and getTagsByInode are done immediately after calling getTagInodesByInode and as you can see getTagInodesByInode already uses the cache in any result case (finding or not results = empty list). What I mean is that every call to the methods, where you want to include 404s, are done using an id (or inode) that does exist in the DB.
- Now, if you want to include the 404's anyway, we think this will create a chaos with the Tag Cache logic already in place, for example let's take a look to the put method from Tag Cache: in order to create a 404tag object as we do with Contentlets we will need more fake information like ID (tag404Id), Name (tag404Name), Host (tag404Host). And that information could end up creating more bug that helping us. Mostly because of we use several cache groups.
With the info we have right now we, really, recommend not adding the 404's to tag cache. Maybe you could help us see in what scenario this methods could churn the DB.
This is good information Oscar, I am glad to hear it. We just need to be sure as good practice, whenever we are using caches either insure that they won't get called with bad values or that they include the 404 pattern.
Thanks for looking into it.