title: How to cache random results using Ember data?
body: <p>Thanks to whoever is reading this and helping out. I'm going to describe what's already working, and then where I'm trying to get to (which I can't figure out):</p>
  
  <p><strong>What's working:</strong>
  In an EmberJS Component, there is a button that populates a textbox with a random string from a given collection of EmberData objects. The <code>model()</code> function queries for all of the objects from the API, and then the <code>random_search()</code> function picks a random one from the list and inserts it into the textbox. The code so far looks like this:</p>
  
  <p>In <code>componennt.js</code>:</p>
  
  <pre><code>export default Component.extend({
    store: service('store'),
    model() {
      return this.store.findAll('randomsearchitem').then(function(items) {
        return items.map(function(item) {
          return {id: item.get('id'), funnnystory: item.get('funnystory')};
        })
      });
    },
    actions: {
      random_search() {
        this.model().then(function(items) {
          $('#searchbar-searchtext').val(items[Math.floor(Math.random() * items.length)]['id']);
          $('#searchbar-form').submit();
        });
      }
    }
  }
  </code></pre>
  
  <p>In <code>view.hbs</code>:</p>
  
  <pre><code>&lt;button onclick={{action "random_search"}}&gt;I'm Feeling Lucky!&lt;/button&gt;
  </code></pre>
  
  <p><strong>What I want:</strong>
  I would like to have:</p>
  
  <ol>
  <li><code>model()</code> query for 15 random objects from the API and cache them locally, persisting between page loads. The API will potentially have a list of 1000's of them and I'd like to implement this logic client-side if possible. If this were SQL the query would look something like <code>SELECT * FROM 'randomsearchitems' LIMIT 15</code></li>
  <li><code>random_search()</code> to select one item, use it, and then discard it from the cache</li>
  <li>Once all 15 have been used once, I want to call the API again for a new list of 15 strings</li>
  <li>Uniqueness does not have to be enforced -- if the list of new objects contains an object that was present in the previous list, that's ok</li>
  </ol>
  
  <p>Thankss</p>