I have a question related to my caching process.
So the initial setup of a shopify account on my app takes a little bit of time because of the api calls to shopify. Grabbing the shop information, product information, etc…
The user will experience a delay while the account is cached. Right now I am using a spinner :)
But I think just starting another thread to finish up the initial load would be a better idea. So I could get the shop information setup the account and then transfer the user to an introduction page. Meanwhile in the background the thread is loading their products and other information.
I have looked around the internet a bit about threading in rails and people seem to recommend staying away from threading with activerecord. Problems with the mysql gem not being thread safe causing issues…
Does anyone have a sound strategy for threading with activerecord? Are there any good resources out there to get up to date information about threading and active record?
Or maybe I should just stick with the spinner :) I could just throw up a modal with a game of tetris while they wait :)
We do a fair bit of local caching in our own apps. Things like the Shop.current call and even products we tend to store in memcached or the database for future accesses.
You can see this in action with PixelPrinter which we released as open source on GitHub.
We have one API application that has to download the entire product catalog of a store to create a specialized output file for powerreviews. In this app we use a similar strategy to what you describe. After the initial login we spin up a background job to fetch all the products of the store. We use our own DJ plugin for that which is currently the most popular choice for background processing in rails applications. Luckily our friends at Heroku added full support for DJ which makes it a great choice on their platform.
|an hour ago|
|3 hours ago|
|4 hours ago|