diff --git a/apps/charging-engine/src/charging/rating_billing.rs b/apps/charging-engine/src/charging/rating_billing.rs index 4080ce1..824dbd5 100644 --- a/apps/charging-engine/src/charging/rating_billing.rs +++ b/apps/charging-engine/src/charging/rating_billing.rs @@ -62,7 +62,7 @@ impl super::ChargingEngine { } pub async fn apply_charging_rules(&self, event: &UsageEvent) -> ChargingResult> { - let mut applied_rules = Vec::new(); + let mut applied_rules = Vec::with_capacity(6); // Max ~6 rules can be applied // Rule 1: Check if user has sufficient credit if !self.check_credit(&event.imsi, event.volume).await? { @@ -159,7 +159,7 @@ impl super::ChargingEngine { .map_err(|e| crate::errors::ChargingError::RedisConnection(e.to_string()))?; let pattern = format!("usage:{}:*", imsi); - let mut keys: Vec = Vec::new(); + let mut keys: Vec = Vec::with_capacity(100); // SCAN batch size // Use SCAN instead of KEYS to avoid blocking Redis let mut cursor = 0u64; @@ -216,7 +216,7 @@ impl super::ChargingEngine { .map_err(|e| crate::errors::ChargingError::RedisConnection(e.to_string()))?; let pattern = "account:*".to_string(); - let mut keys: Vec = Vec::new(); + let mut keys: Vec = Vec::with_capacity(100); // SCAN batch size // Use SCAN instead of KEYS to avoid blocking Redis let mut cursor = 0u64;