```python:inference/core/workflows/core_steps/trackers/_base.py
from collections import deque


class InstanceCache:

    def __init__(self, size: int):
        size = max(1, size)
        self._cache_inserts_track = deque(maxlen=size)
        self._cache = set()

    def record_instance(self, tracker_id: int) -> bool:
        """Record a tracker ID and return whether it was previously seen.

        Returns:
            True if the tracker_id was already in the cache (seen before),
            False if this is its first appearance.
        """
        in_cache = tracker_id in self._cache
        if not in_cache:
            if len(self._cache) >= self._cache_inserts_track.maxlen:
                to_drop = self._cache_inserts_track.popleft()
                self._cache.remove(to_drop)
            self._cache_inserts_track.append(tracker_id)
            self._cache.add(tracker_id)
        return in_cache
```