discourse/migrations/lib/common/set_store.rb
Gerhard Schlager 53d7a756d6
DEV: Add Migrations::SetStore to work with nested sets of data (#33593)
There are concrete implementations for a simple set, a key-value store,
and nested sets with 2 or 3 keys. The API stays the same for all
implementations and the performances is more or less the same as without
the wrapper (at least with YJIT enabled).
2025-07-24 12:11:41 +02:00

19 lines
360 B
Ruby

# frozen_string_literal: true
module Migrations
module SetStore
def self.create(depth)
case depth
when 0
SimpleSet.new
when 1
KeyValueSet.new
when 2
TwoKeySet.new
when 3
ThreeKeySet.new
else
raise ArgumentError, "Unsupported nesting depth: #{depth}"
end
end
end
end