From Cached to Common database for a very quick start-up phase.

This commit is contained in:
Philippe Pittoli 2024-12-15 01:30:25 +01:00
parent 6404946d15
commit 65dfa736f4

View File

@ -7,16 +7,16 @@ require "./service.cr"
require "dodb" require "dodb"
class DNSManager::Storage class DNSManager::Storage
getter domains : DODB::Storage::Cached(Domain) getter domains : DODB::Storage::Common(Domain)
getter domains_by_name : DODB::Trigger::IndexCached(Domain) getter domains_by_name : DODB::Trigger::IndexCached(Domain)
getter domains_by_share_key : DODB::Trigger::IndexCached(Domain) getter domains_by_share_key : DODB::Trigger::IndexCached(Domain)
getter domains_by_transfer_key : DODB::Trigger::IndexCached(Domain) getter domains_by_transfer_key : DODB::Trigger::IndexCached(Domain)
getter domains_by_owners : DODB::Trigger::Tags(Domain) getter domains_by_owners : DODB::Trigger::Tags(Domain)
getter zones : DODB::Storage::Cached(Zone) getter zones : DODB::Storage::Common(Zone)
getter zones_by_domain : DODB::Trigger::IndexCached(Zone) getter zones_by_domain : DODB::Trigger::IndexCached(Zone)
getter tokens : DODB::Storage::Cached(Token) getter tokens : DODB::Storage::Common(Token)
getter tokens_by_uuid : DODB::Trigger::IndexCached(Token) getter tokens_by_uuid : DODB::Trigger::IndexCached(Token)
getter tokens_by_domain : DODB::Trigger::Partition(Token) getter tokens_by_domain : DODB::Trigger::Partition(Token)
@ -32,7 +32,7 @@ class DNSManager::Storage
end end
def initialize(@root : String, reindex : Bool = false) def initialize(@root : String, reindex : Bool = false)
@domains = DODB::Storage::Cached(Domain).new "#{@root}/domains" @domains = DODB::Storage::Common(Domain).new "#{@root}/domains", 5_000
@domains_by_name = @domains.new_index "name", &.name @domains_by_name = @domains.new_index "name", &.name
@domains_by_share_key = @domains.new_index "share-key", do |d| @domains_by_share_key = @domains.new_index "share-key", do |d|
if k = d.share_key if k = d.share_key
@ -49,9 +49,9 @@ class DNSManager::Storage
end end
end end
@domains_by_owners = @domains.new_tags "owners", &.owners.map &.to_s @domains_by_owners = @domains.new_tags "owners", &.owners.map &.to_s
@zones = DODB::Storage::Cached(Zone).new "#{@root}/zones" @zones = DODB::Storage::Common(Zone).new "#{@root}/zones", 5_000
@zones_by_domain = @zones.new_index "domain", &.domain @zones_by_domain = @zones.new_index "domain", &.domain
@tokens = DODB::Storage::Cached(Token).new "#{@root}/tokens" @tokens = DODB::Storage::Common(Token).new "#{@root}/tokens", 5_000
@tokens_by_uuid = @tokens.new_index "uuid", &.uuid @tokens_by_uuid = @tokens.new_index "uuid", &.uuid
@tokens_by_domain = @tokens.new_partition "domain", &.domain @tokens_by_domain = @tokens.new_partition "domain", &.domain