Added cache trimming. All updates are under a distributed lock.