Implement a function similar to an LRU cache.
Use operations to represent cache actions as ['put', key, value] or ['get', key]. Return a list containing the result of each get, using -1 for a missing key. The cache must evict the least recently used key when its capacity is exceeded, and both operations should run in O(1) time.
def lru_cache(operations, capacity):