<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def is_duplicated(self, item):
 """Check whether the item has been in the cache If the item has not been seen before, then hash it and put it into the cache, otherwise indicates the item is duplicated. When the cache size exceeds capacity, discard the earliest items in the cache. Args: item (object):
 The item to be checked and stored in cache. It must be immutable or a list/dict. Returns: bool: Whether the item has been in cache. """

        if isinstance(item, dict):
            hashable_item = json.dumps(item, sort_keys=True)
        elif isinstance(item, list):
            hashable_item = frozenset(item)
        else:
            hashable_item = item
        if hashable_item in self._cache:
            return True
        else:
            if self.cache_capacity > 0 and len(
                    self._cache) >= self.cache_capacity:
                self._cache.popitem(False)
            self._cache[hashable_item] = 1
            return False