apply the LRU cache algorithm