Permalink
Browse files

assets.cache_store now defaults to filesystem. You will want to share…

… tmp/assets_cache between deploys.
  • Loading branch information...
josevalim committed Jul 13, 2011
1 parent a91afeb commit d0f05a6fee3af1d7d6eea3b0b7e60a0fdd5cc170
@@ -63,8 +63,8 @@ def asset_environment(app)
env.logger = Rails.logger
- if env.respond_to?(:cache)
- env.cache = assets.cache_store || Rails.cache
+ if env.respond_to?(:cache) && assets.cache_store != false
+ env.cache = ActiveSupport::Cache.lookup_store(assets.cache_store) || Rails.cache
end
if assets.compress
@@ -30,13 +30,15 @@ def initialize(*)
@log_level = nil
@middleware = app_middleware
@generators = app_generators
+ @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
@assets = ActiveSupport::OrderedOptions.new
@assets.enabled = false
@assets.paths = []
@assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
@assets.prefix = "/assets"
+ @assets.cache_store = [ :file_store, "#{root}/tmp/assets_cache/" ]
@assets.js_compressor = nil
@assets.css_compressor = nil
end
@@ -70,7 +72,6 @@ def paths
paths.add "public/javascripts"
paths.add "public/stylesheets"
paths.add "tmp"
- paths.add "tmp/cache"
paths
end
end
@@ -95,16 +96,6 @@ def database_configuration
YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
end
- def cache_store
- @cache_store ||= begin
- if File.exist?("#{root}/tmp/cache/")
- [ :file_store, "#{root}/tmp/cache/" ]
- else
- :memory_store
- end
- end
- end
-
def log_level
@log_level ||= Rails.env.production? ? :info : :debug
end
@@ -117,7 +117,8 @@ def test
end
def tmp
- empty_directory_with_gitkeep "tmp/cache"
+ empty_directory "tmp/cache"
+ empty_directory "tmp/assets_cache"
end
def vendor
@@ -4,7 +4,7 @@ namespace :tmp do
desc "Creates tmp directories for sessions, cache, sockets, and pids"
task :create do
- FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids ))
+ FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids tmp/assets_cache ))
end
namespace :sessions do
@@ -18,6 +18,7 @@ namespace :tmp do
# desc "Clears all files and directories in tmp/cache"
task :clear do
FileUtils.rm_rf(Dir['tmp/cache/[^.]*'])
+ FileUtils.rm_rf(Dir['tmp/assets_cache/[^.]*'])
end
end
@@ -48,7 +48,6 @@ def assert_not_in_load_path(*path)
assert_path @paths["vendor"], "vendor"
assert_path @paths["vendor/plugins"], "vendor/plugins"
assert_path @paths["tmp"], "tmp"
- assert_path @paths["tmp/cache"], "tmp/cache"
assert_path @paths["config"], "config"
assert_path @paths["config/locales"], "config/locales/en.yml"
assert_path @paths["config/environment"], "config/environment.rb"
@@ -34,6 +34,7 @@
vendor
vendor/assets
vendor/plugins
+ tmp/assets_cache
tmp/cache
)

3 comments on commit d0f05a6

@cgriego

This comment has been minimized.

Show comment Hide comment
@cgriego

cgriego Jul 18, 2011

Contributor

@josevalim What exactly gets placed in this cache that is safe to reuse across deploys? Deploys that could change the location and/or contents of asset files?

Contributor

cgriego replied Jul 18, 2011

@josevalim What exactly gets placed in this cache that is safe to reuse across deploys? Deploys that could change the location and/or contents of asset files?

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Jul 18, 2011

Contributor
Contributor

josevalim replied Jul 18, 2011

@cgriego

This comment has been minimized.

Show comment Hide comment
@cgriego

cgriego Jul 18, 2011

Contributor

@josevalim Thanks for the clarification.

Is there a particular reason that this needs to be shared, or is it just a nice to have? I'm thinking of users deployed on EngineYard's AppCloud where the closest thing to a shared filesystem is S3.

Contributor

cgriego replied Jul 18, 2011

@josevalim Thanks for the clarification.

Is there a particular reason that this needs to be shared, or is it just a nice to have? I'm thinking of users deployed on EngineYard's AppCloud where the closest thing to a shared filesystem is S3.

Please sign in to comment.