mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 01:17:36 +08:00
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).
19 lines
360 B
Ruby
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
|