Skip to content

Commit

Permalink
Segregate the various compile caches
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jan 13, 2022
1 parent a95c258 commit aa7d24a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/bootsnap/compile_cache/iseq.rb
Expand Up @@ -7,7 +7,11 @@ module Bootsnap
module CompileCache
module ISeq
class << self
attr_accessor(:cache_dir)
attr_reader(:cache_dir)

def cache_dir=(cache_dir)
@cache_dir = cache_dir.end_with?("/") ? "#{cache_dir}iseq" : "#{cache_dir}-iseq"
end
end

has_ruby_bug_18250 = begin # https://bugs.ruby-lang.org/issues/18250
Expand Down
7 changes: 6 additions & 1 deletion lib/bootsnap/compile_cache/json.rb
Expand Up @@ -6,7 +6,12 @@ module Bootsnap
module CompileCache
module JSON
class << self
attr_accessor(:msgpack_factory, :cache_dir, :supported_options)
attr_accessor(:msgpack_factory, :supported_options)
attr_reader(:cache_dir)

def cache_dir=(cache_dir)
@cache_dir = cache_dir.end_with?("/") ? "#{cache_dir}json" : "#{cache_dir}-json"
end

def input_to_storage(payload, _)
obj = ::JSON.parse(payload)
Expand Down
8 changes: 6 additions & 2 deletions lib/bootsnap/compile_cache/yaml.rb
Expand Up @@ -6,8 +6,12 @@ module Bootsnap
module CompileCache
module YAML
class << self
attr_accessor(:msgpack_factory, :cache_dir, :supported_options)
attr_reader(:implementation)
attr_accessor(:msgpack_factory, :supported_options)
attr_reader(:implementation, :cache_dir)

def cache_dir=(cache_dir)
@cache_dir = cache_dir.end_with?("/") ? "#{cache_dir}yaml" : "#{cache_dir}-yaml"
end

def precompile(path, cache_dir: YAML.cache_dir)
Bootsnap::CompileCache::Native.precompile(
Expand Down

0 comments on commit aa7d24a

Please sign in to comment.