```ts
export function slotHits(keys: number[], slots: number): number {
  if (!Number.isInteger(slots) || slots <= 0) {
    throw new Error("Slot count must be a positive integer.");
  }

  const cache: Record<number, number> = {};

  let hits = 0;

  for (const key of keys) {
    if (!Number.isInteger(key)) {
      throw new Error("Each key must be an integer.");
    }

    const slotIndex = Math.abs(key % slots);

    if (cache[slotIndex] === key) {
      hits++;
    } else {
      cache[slotIndex] = key;
    }
  }

  return hits;
}
```