Duration Units
Human-readable duration units for timeout and duration configuration values
Radiator Server supports human-readable duration units for all timeout and duration configuration values, making configuration files more readable and maintainable.
Overview
Duration values can be specified using intuitive unit suffixes instead of raw millisecond values.
Supported Units
| Unit | Description | Equivalent (base) |
|---|---|---|
| ms | Milliseconds | 0.001 seconds |
| s | Seconds | 1000 milliseconds |
| m | Minutes | 60 seconds |
| h | Hours | 60 minutes (3600 seconds) |
| d | Days | 24 hours |
| w | Weeks | 7 days |
| M | Months | 30 days (fixed length) |
| y | Years | 365 days (fixed length) |
Note: Months and years use fixed lengths and are not calendar-aware. A month is always 30 days, and a year is always 365 days (no leap year adjustment).
Basic Usage
Simple Duration Values
backends {
radius "upstream" {
server "192.168.1.10" {
timeout 5s; # 5 seconds
idle_timeout 30m; # 30 minutes
}
}
}
Cache Expiration
caches {
cache "user_sessions" {
timeout 1h; # Cache entries expire after 1 hour
}
cache "temp_data" {
timeout 15m; # Short-lived cache
}
}
Combined Duration Values
You can combine multiple units for precise duration specifications:
backends {
http "api" {
url "https://api.example.com";
timeout 1m30s; # 1 minute and 30 seconds (90 seconds total)
}
ldap "directory" {
server "ldap.example.com" {
url "ldap://ldap.example.com:389/";
timeout 2h30m; # 2 hours and 30 minutes
}
}
}
Where Duration Units Apply
Duration units are supported in all timeout and duration configurations across the system:
- Backend timeouts: HTTP, LDAP, and RADIUS backend server timeouts
- Cache timeouts: Cache entry expiration times
- Idle timeouts: RADIUS backend server idle connection timeouts
- Custom timeout configurations: Any user-defined timeout values
Best Practices
-
Use appropriate units: Choose the most natural unit for your use case
- Short timeouts: use seconds (
5s,30s) - Medium timeouts: use minutes (
5m,30m) - Long timeouts: use hours or days (
2h,1d)
- Short timeouts: use seconds (
-
Combine units for clarity:
1m30sis clearer than90sfor some contexts -
Be consistent: Use similar unit patterns across your configuration for readability
Error Handling
Invalid unit suffixes will result in configuration parsing errors with helpful messages indicating the supported units and correct syntax.