```typescript
/**
 * LRU Cache implementation with fixed capacity.
 */
export class LruCache<K, V> {
  private readonly capacity: number;
  private readonly cache = new Map<K, { value: V; timestamp: number }>();
  private timestamp = 0;

  constructor(capacity: number) {
    if (typeof capacity !== 'number' || capacity <= 0 || !Number.isInteger(capacity)) {
      throw new Error('Capacity must be a positive integer');
    }
    this.capacity = capacity;
  }

  get(key: K): V | undefined {
    const entry = this.cache.get(key);
    if (!entry) return undefined;
    entry.timestamp = ++this.timestamp;
    return entry.value;
  }

  set(key: K, value: V): void {
    if (this.cache.has(key)) {
      this.cache.get(key)!.timestamp = ++this.timestamp;
    } else {
      if (this.cache.size >= this.capacity) {
        const oldestEntry = Array.from(this.cache.entries())
          .sort((a, b) => a[1].timestamp - b[1].timestamp)[0];
        this.cache.delete(oldestEntry[0]);
      }
      this.cache.set(key, { value, timestamp: ++this.timestamp });
    }
  }

  get size(): number {
    return this.cache.size;
  }
}
```