lib/cache/repositories/splits_repository.rb in splitclient-rb-3.2.2 vs lib/cache/repositories/splits_repository.rb in splitclient-rb-3.2.3.pre.rc1

- old
+ new

@@ -10,43 +10,43 @@ def initialize(adapter, config) @adapter = adapter @config = config - @adapter.set_string(namespace_key('splits.till'), '-1') - @adapter.initialize_map(namespace_key('segments.registered')) + @adapter.set_string(namespace_key('.splits.till'), '-1') + @adapter.initialize_map(namespace_key('.segments.registered')) end def add_split(split) return unless split[:name] - @adapter.set_string(namespace_key("split.#{split[:name]}"), split.to_json) + @adapter.set_string(namespace_key(".split.#{split[:name]}"), split.to_json) end def remove_split(name) - @adapter.delete(namespace_key("split.#{name}")) + @adapter.delete(namespace_key(".split.#{name}")) end def get_splits(names, slice = SPLITS_SLICE) splits = {} names.each_slice(slice) do |splits_slice| splits.merge!( @adapter - .multiple_strings(splits_slice.map { |name| namespace_key("split.#{name}") }) - .map { |name, data| [name.gsub(namespace_key('split.'), ''), data] }.to_h + .multiple_strings(splits_slice.map { |name| namespace_key(".split.#{name}") }) + .map { |name, data| [name.gsub(namespace_key('.split.'), ''), data] }.to_h ) end splits.map do |name, data| parsed_data = data ? JSON.parse(data, symbolize_names: true) : nil [name.to_sym, parsed_data] end.to_h end def get_split(name) - split = @adapter.string(namespace_key("split.#{name}")) + split = @adapter.string(namespace_key(".split.#{name}")) JSON.parse(split, symbolize_names: true) if split end def splits @@ -59,43 +59,43 @@ splits_hash end # Return an array of Split Names excluding control keys like splits.till def split_names - @adapter.find_strings_by_prefix(namespace_key('split.')) - .map { |split| split.gsub(namespace_key('split.'), '') } + @adapter.find_strings_by_prefix(namespace_key('.split.')) + .map { |split| split.gsub(namespace_key('.split.'), '') } end def set_change_number(since) - @adapter.set_string(namespace_key('splits.till'), since) + @adapter.set_string(namespace_key('.splits.till'), since) end def get_change_number - @adapter.string(namespace_key('splits.till')) + @adapter.string(namespace_key('.splits.till')) end def set_segment_names(names) return if names.nil? || names.empty? names.each do |name| - @adapter.add_to_set(namespace_key('segments.registered'), name) + @adapter.add_to_set(namespace_key('.segments.registered'), name) end end def exists?(name) - @adapter.exists?(namespace_key("split.#{name}")) + @adapter.exists?(namespace_key(".split.#{name}")) end def ready? - @adapter.string(namespace_key('cache.ready.splits')).to_i != -1 + @adapter.string(namespace_key('.splits.ready')).to_i != -1 end def not_ready! - @adapter.set_string(namespace_key('cache.ready.splits'), -1) + @adapter.set_string(namespace_key('.splits.ready'), -1) end def ready! - @adapter.set_string(namespace_key('cache.ready.splits'), Time.now.utc.to_i) + @adapter.set_string(namespace_key('.splits.ready'), Time.now.utc.to_i) end end end end end