## LRU 概述

This algorithm requires keeping track of what was used when, which is expensive if one wants to make sure the algorithm always discards the least recently used item. General implementations of this technique require keeping “age bits” for cache-lines and track the “Least Recently Used” cache-line based on age-bits. – from Wikipedia

LRU 算法的思想是淘汰最近没有使用的缓存。

Example:

## 分析

get 方法：如果元素不存在，直接返回 -1。如果元素存在，取出之后需要将当前元素移动到队列的头部。

put 方法：如果元素不存在，直接将元素添加到队列头部，如果元素存在，将元素移动到队列头部。