title: LRU cache implementation in Javascript
body: <p>Java has LinkedHashMap which <a href="http://tech.puredanger.com/2007/09/23/linkedhashmap-trick/" rel="noreferrer">gets you 99% there to an LRU cache</a>.</p>
  
  <p>Is there a Javascript implementation of an LRU cache, preferably from a reputable source, that is:</p>
  
  <ol>
  <li>understandable</li>
  <li>efficient (amortized O(1) get/put/delete)</li>
  </ol>
  
  <p>? I've been searching on the web but couldn't find one; I thought I found one on <a href="http://web.archive.org/web/20150902003300/http://ajaxpatterns.org:80/Browser-Side_Cache" rel="noreferrer">Ajax Design Patterns</a> but it glosses over the <code>sendToTail()</code> method and has O(n) performance (presumably, since the queue and associative array are split up).</p>
  
  <p>I suppose I could write my own, but I've learned the hard way that reinventing the wheel for core algorithms can be hazardous to one's health :/</p>