I was reading about caching mechanism that Yii implements and possible other frameworks/techniques/databases as well. If I got that right, there’s a step that you have to specify a condition to expire the cache. If you have a user row with a timestamp field, you could use this timestamp to verify it’s (the row) consistency. If you have a log table with non erasable/updatable rows, you could use count(*) to make sure that you have an up to date cached result of that query/table.
Now, to my question:
Imagine that I have 13 tables. Is it useful to create another table (CacheTable) that has only one column of timestamp type and store 13 rows, each row telling me when was the last time that one of the other tables was updated/deleted/inserted and use this CacheTable to verify the expiring condition of all my cached queries?
That’s a good solution if you plan to create triggers to update the CacheTable, you don’t want to do the updates in your code as it will become hard to maintain later.