Skip to content

Instantly share code, notes, and snippets.

@jcblw
Created July 11, 2013 04:25
Show Gist options
  • Save jcblw/5972522 to your computer and use it in GitHub Desktop.
Save jcblw/5972522 to your computer and use it in GitHub Desktop.
Advanced Caching for multi model calls in rendr to make them look a bunch of single model calls
// this is to direct check the model store
// App.fetcher.modelStore.get("user", "bork", true);
// ^ ^ ^
// model userid should return
// to store a collection and to 'fake' a call
// you create a collection with the options the fetch params
// then you say collection.store();
// that should fake an individual call so if one is made
// bam we have the model
// work flow on how this will work
// 1. First an arr of ids and a options object will be passed to us
// the options will contain a model and collection name
// so we can check the cache and store the call if we need to
// 2. Second we will check our cache to see which of the models we have
// and save those in our queue so we can add them to the model later
// 3. Third if there is no call cached ( which we have to check for )
// then store it so when a fetch using those params is made
// instead of fetching it will then grab it from cache
// 4. Forth if we still have items not fetched... fetch them add the cached
// results to the collection returned return that back to the program
// 5. This can happen after the fact that the results are returned... take the
// response and throw it through the a function that can then store all
// of the indivdual calls as cached calls so we can grab those from cache
// even tho we have never made them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment