title: Caffeine: Memoize or Cache Builder a Big List of Items?
body: <p>As a disclaimer, I'm new to Caffeine and exploring out this lightweight approach.</p>
  
  <p>I have a collection that is fetched from a database that consists of more than 20K of simple ItemLOV two-attribute objects. They are pulled, converted / cast as:</p>
  
  <pre><code>List&lt;OutletsSelectBox&gt; result = new ArrayList&lt;&gt;();
  for(int i = 0; i&lt;objlist.size(); i++){
     Object row = objlist.get(i);
     Object[] item = (Object[]) row;
     SkusSelectBox ssb = new SkusSelectBox();
     ssb.setItemId(String.valueOf(item[0].toString()));
     ssb.setItemName(String.valueOf(item[1].toString()));
     result.add(ssb);
  }
  </code></pre>
  
  <p>What I'm looking for is to set the cached items into the setItems method of a third-party component that I have. The setItems, a public void method, allows three options to be parsed either in:</p>
  
  <ul>
  <li><code>public void setItems(final Collection&lt;T&gt; items)</code></li>
  <li><code>public void setItems(Stream&lt;T&gt; streamOfItems)</code></li>
  <li><code>public void setItems(@SuppressWarnings("unchecked") final T... items)</code></li>
  </ul>
  
  <p>I noticed that there is a similar posting: <a href="https://stackoverflow.com/questions/39731980/what-is-a-simple-way-to-cache-a-list-or-other-collection-in-java">Simple Way to Cache a List of Collection in Java</a> but what I am not sure about is:</p>
  
  <ol>
  <li>Should my list should use a memoize or the cache builder?</li>
  <li>If memoize is best used, is the Supplier cast used in the sample code (in the linked posting) is from the java.util package or the Guava package? </li>
  <li>Does the cache needs to be recast into a list again prior to be set into
  the setItems method?</li>
  <li>For the memoizeWithExpiration method, can the existing code above be
  transposed / moved as the delegate parameter instead of a empty
  Supplier Collection or do we need to do it within the get() method?
  It's great to have an existing list parsed in as the delegate, but
  not very sure of it though. </li>
  </ol>