Fixing this is going to require extending the ccache operations table, because while there is a set_flags operation, there is no get_flags operation, so saving and restoring the old flags can't be done under the current interface. Fortunately, the struct is internal, and we'd just be adding a new function.