Adds event-driven cache flushing