I found many of the Python solutions for this problem to be almost unreadable. This is my version that overrides python's ordereddict that is much shorter and easier to understand

```
class LRUCache(collections.OrderedDict):
# @param capacity, an integer
def __init__(self, capacity):
self.capacity = capacity
super(LRUCache, self).__init__()
# @return an integer
def get(self, key):
if key in self:
self[key] = self[key]
return self[key]
return -1
# @param key, an integer
# @param value, an integer
# @return nothing
def set(self, key, value):
self[key] = value
if len(self) > self.capacity:
self.popitem(0)
def __setitem__(self, key, value):
if key in self:
del self[key]
collections.OrderedDict.__setitem__(self, key, value)
```