Question
Build an LRU cache whose capacity is the total weight of stored entries rather than the number of keys.
```python
class WeightedLRUCache:
def __init__(self, capacity: int): ...
def get(self, key: str) -> int: ...
def put(self, key: str, value: int, size: int) -> None: ...
```
`get` returns `-1` when absent and marks a hit most-recently used. `put` inserts or replaces a key. On replacement, remove the old weight before checking capacity. Evict least-recently used entries until the new value fits; one insertion may evict several entries. A non-positive size or a size exceeding capacity raises `ValueError` without changing the cache. Exact fits are valid.
Target average `O(1)` time for `get` and for each individual insert, update, or eviction.
The provided `run_case` owns fixture dispatch and is not candidate work. Capacity is a nonnegative integer; keys are strings and values are integers. A zero-capacity cache is valid but admits no positive-sized entry. Each successful `put` returns `None` and marks the inserted/replaced key most-recently used. The whole insertion may take time proportional to the number of evicted entries.
Reject noninteger capacity or size (including booleans) with `ValueError`; invalid size rejection must occur before replacement or eviction.
## Staged follow-ups
1. Implement with an explicit hash map and doubly linked list.
2. Add per-entry expiry while preserving recency semantics.
3. Make operations thread-safe without exposing partial updates.
4. Compare recency eviction with frequency-per-weight policies.