diff --git a/lib/tiktoken_ruby/encoding.rb b/lib/tiktoken_ruby/encoding.rb index 93dd754..21cd70d 100644 --- a/lib/tiktoken_ruby/encoding.rb +++ b/lib/tiktoken_ruby/encoding.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Tiktoken::Encoding - MUTEX = Mutex.new + CACHE_MUTEX = Mutex.new attr_reader :name @@ -17,7 +17,7 @@ def self.for_name(encoding) # @param encoding [Symbol] The name of the encoding to load # @return [Tiktoken::Encoding] The encoding instance def self.for_name_cached(encoding) - MUTEX.synchronize do + CACHE_MUTEX.synchronize do @encodings ||= {} @encodings[encoding.to_sym] ||= Tiktoken::Encoding.for_name(encoding) end