Fix plug and unplug in cache layer