<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def contains(self, key, counter_id):
 """ Return whether a counter_id is present for a given instance key. If the key is not in the cache, raises a KeyError. """

        with self._lock:
            return counter_id in self._metadata[key]