Matthew Hardin wrote:
It might be less intrusive codewise and more flexible if we left the behavior of cache expiration the same and added a parameter to each template called "Time to Refresh" (TTR). Then you set long or unlimited cache expirations, which are always in effect, but set a shorter TTR that would trigger an asynchronous refresh when the TTR expired. If the db is not available these refreshes will simply fail, but the data will remain in the cache at least until it's expired by the usual means.
This gives the solution designer the option of deciding how long a system can run disconnected while still being able to separately determine how stale the contents of the cache will get when connected. It also means that pcache itself doesn't need to switch modes based on whether it thinks it's connected to a db or not, and it fact may not need to even know if it is connected or not.
There is still room in this design for a flag that controls whether pcache should behave as if it's disconnected or connected, but I'm not sure how useful that is given the changes described above.
The TTR feature is now available for testing in HEAD. (As well as the offline mode switch.) The TTR behavior is as follows: 1) default is off 2) refreshes are only performed for regular (positive) queries. Negative queries and sizelimit queries are not refreshed. 3) If a query has been referenced in the time since the last refresh, then the expiration time will be extended. So queries that are actively used can stay in the cache indefinitely. 4) If a query has not been referenced, the expiration time will be left unchanged. The query will continue to be refreshed up till its expiration time, at which point it will be removed as normal.
A typical configuration for disconnected operation would use TTLs on the order of a few days, with TTR set at whatever refresh interval makes sense.
Still need to look at Bind caching.