Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.
get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.
To increase the efficiency, use a hash map to record each key to the corresponding node. Use a double linked the list to store the key value pair, because it is quick for inserting and deleting nodes. For each get operation, move node which contains the key to the head of the list. For each set operation, if it is a new key, and the size will be greater than the capacity, then delete the last node, and insert the new node to the head.