refactor: use BTreeMap for cached registration info

This commit is contained in:
Matthias Ahouansou 2024-03-22 17:51:15 +00:00
parent 0bb28f60cf
commit 5c650bb67e
No known key found for this signature in database

View file

@ -1,6 +1,6 @@
mod data; mod data;
use std::collections::HashMap; use std::collections::BTreeMap;
pub use data::Data; pub use data::Data;
@ -97,12 +97,12 @@ impl TryFrom<Registration> for RegistrationInfo {
pub struct Service { pub struct Service {
pub db: &'static dyn Data, pub db: &'static dyn Data,
registration_info: RwLock<HashMap<String, RegistrationInfo>>, registration_info: RwLock<BTreeMap<String, RegistrationInfo>>,
} }
impl Service { impl Service {
pub fn build(db: &'static dyn Data) -> Result<Self> { pub fn build(db: &'static dyn Data) -> Result<Self> {
let mut registration_info = HashMap::new(); let mut registration_info = BTreeMap::new();
// Inserting registrations into cache // Inserting registrations into cache
for appservice in db.all()? { for appservice in db.all()? {
registration_info.insert( registration_info.insert(