Implement a common data structure or algorithm (typically Medium-level LeetCode difficulty). Implement an LRU cache that supports get and put operations in O(1) average time. The function receives an operation list and capacity, and returns the results of all get operations in order. Use operations shaped as ["get", key] or ["put", key, value].
def lru_cache(operations, capacity):