code: function BoundedCache(newMaxSize) {
      var maxSize = newMaxSize;
      var map = {};
      var size = 0;
      var counter = -1;
  
      /**
       * Adds a key-value pair to the cache. If the cache is at its size limit,
       * the least-recently used entry is evicted.
       */
      this.put = function(key, value) {
          if (map[key]) {
              // entry already exists
              map[key] = { usage: ++counter, value: value };
          }
          else {
              map[key] = { usage: ++counter, value: value };
              ++size;
  
              if (size > maxSize) {
                  // remove the least recently used item
                  var minUsage = counter;
                  var keyToRemove = key;
  
                  for (var key in map) {
                      if (map[key].usage < minUsage) {
                          minUsage = map[key].usage;
                          keyToRemove = key;
                      }
                  }
  
                  this.remove(keyToRemove);
              }
          }
      };
  
      /**
       * Returns a cache item by its key, and updates its use status.
       */
      this.get = function(key) {
          if (map[key]) {
              map[key].usage = ++counter;
              return map[key].value;
          }
  
          return null;
      };
  
      /**
       * Removes a cache item by its key.
       */
      this.remove = function(key) {
          if (map[key]) {
              delete map[key];
              --size;
  
              if (size == 0) {
                  counter = -1;
              }
          }
      }
  
      /**
       * Clears all entries in the cache.
       */
      this.clear = function() {
          map = {};
          size = 0;
          counter = -1;
      };
  }
docs: Cache class.
  
  @param newMaxSize  the maximum number of entries to keep in the cache.