From aa7d24a3a8d71fa2f5d1d7dd1cf98f9790f01df9 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 13 Jan 2022 18:09:29 +0100 Subject: [PATCH] Segregate the various compile caches --- lib/bootsnap/compile_cache/iseq.rb | 6 +++++- lib/bootsnap/compile_cache/json.rb | 7 ++++++- lib/bootsnap/compile_cache/yaml.rb | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/bootsnap/compile_cache/iseq.rb b/lib/bootsnap/compile_cache/iseq.rb index e926eb4f..4335cf76 100644 --- a/lib/bootsnap/compile_cache/iseq.rb +++ b/lib/bootsnap/compile_cache/iseq.rb @@ -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 diff --git a/lib/bootsnap/compile_cache/json.rb b/lib/bootsnap/compile_cache/json.rb index 36d0c6be..ed1d98c2 100644 --- a/lib/bootsnap/compile_cache/json.rb +++ b/lib/bootsnap/compile_cache/json.rb @@ -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) diff --git a/lib/bootsnap/compile_cache/yaml.rb b/lib/bootsnap/compile_cache/yaml.rb index 71fb588f..55456ae2 100644 --- a/lib/bootsnap/compile_cache/yaml.rb +++ b/lib/bootsnap/compile_cache/yaml.rb @@ -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(