Check for existing persistent cache files on demand#26
Merged
oesmith merged 6 commits intooesmith:masterfrom Dec 15, 2013
Merged
Check for existing persistent cache files on demand#26oesmith merged 6 commits intooesmith:masterfrom
oesmith merged 6 commits intooesmith:masterfrom
Conversation
added 6 commits
August 24, 2013 01:12
Collaborator
|
I've been using the changes in this pull request for several weeks and they works great! Thanks for doing this. Thought I'd share another benefit I got out of lazy-loading the cache files. When authoring tests that dynamically hit external APIs, a lot of extra cache files can be created that you don't want in the codebase. With the changes in this pull request, I was able to implement the following in my spec_helper.rb to delete any cache files not used when running the full test suite via config.after(:suite, type: :feature) do
if ENV['DELETE_UNUSED_CACHE'] && defined?(Billy)
puts "\n*** ALL UNUSED CACHE FILES WILL BE DELETED ***"
local_cache_path = Rails.root.join(Billy.config.cache_path)
used_cache_files = Billy.proxy.instance_variable_get(:@cache)
Dir.glob(local_cache_path+'*.yml') do |full_filename|
filename = full_filename.gsub(local_cache_path.to_s, '')
unless used_cache_files[filename.gsub('.yml','')]
puts " - DELETING #{filename}"
File.delete(local_cache_path+filename)
end
end
end
end |
Author
|
@ronwsmith I'm glad you found the pull request useful. I like your deletion logic and I will try that out. |
oesmith
added a commit
that referenced
this pull request
Dec 15, 2013
Check for existing persistent cache files on demand
Owner
|
Merged, thanks! |
Author
|
Thanks for merging this in! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I was using puffing_billy I noticed that for the first request it did not check for a persisted cache file. Later, I realized that I was not calling Billy.proxy.restore_cache in my config and also did not notice the Billy.cache.load_dir method.
However, I had already written additional logic to check for a persisted cache entry on demand. And I think this may be an improvement for the existing approach for a few reasons: