<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def territory(self):
 """ Return the cached territory occupied by the piece. """

        cache_key = (
            self.board.length, self.board.height, self.uid, self.index)
        if cache_key not in self.territory_cache:
            vector = self.compute_territory()
            self.territory_cache[cache_key] = vector
        else:
            vector = self.territory_cache[cache_key]
        return vector