Implement a cache with get and put operations that supports eviction of the least recently used item.
Implement def lru_cache(capacity, operations):, where capacity is a positive integer and operations is a list of [get, key] or [put, key, value] lists. Return the values produced by successful and unsuccessful get operations, using -1 for a missing key. Both get and put on an existing key mark it as most recently used. The implementation should achieve O(1) average time per operation.
def lru_cache(capacity, operations):