Skip to content

Instantly share code, notes, and snippets.

@caryfitzhugh
Created July 18, 2013 18:58
Show Gist options
  • Save caryfitzhugh/6031998 to your computer and use it in GitHub Desktop.
Save caryfitzhugh/6031998 to your computer and use it in GitHub Desktop.
stream offsetting
def add_cached_hits(cache_results, start, size)
number_to_pull_from_cache = [0, (cache_results.length - start)].max
# DO the search
if (number_to_pull_from_cache > 0)
# Take number_to_pull from the *END* of the cache_results
results = cache_results[ ...??] + search_results
# Then slice that # off the end of the results
results = results[0..(-1 * number_to_pull_from_cache)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment