Last active
January 2, 2016 01:39
-
-
Save patmaddox/8231576 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'timeout' | |
| class SearchesController | |
| def post | |
| search = Search.create! params[:search] | |
| begin | |
| timeout(3) do | |
| while result.nil? | |
| result = Cache.fetch(search.results_id) | |
| end | |
| end | |
| render json: result | |
| rescue TimeoutError | |
| render status: WHATEVER_CODE, href: search_results_url(search) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment