64 lines
1.4 KiB
Markdown
64 lines
1.4 KiB
Markdown
# Wildcard Policies
|
|
|
|
Set default retention policies for all streams using wildcard ("*") pattern.
|
|
|
|
## Overview
|
|
|
|
Wildcard policies provide a default retention configuration that applies to all streams unless overridden by stream-specific policies.
|
|
|
|
## Configuration
|
|
|
|
```csharp
|
|
// Default policy for all streams
|
|
var defaultPolicy = new RetentionPolicyConfig
|
|
{
|
|
StreamName = "*", // Wildcard applies to all streams
|
|
MaxAge = TimeSpan.FromDays(365),
|
|
Enabled = true
|
|
};
|
|
|
|
await _policyStore.SetPolicyAsync(defaultPolicy);
|
|
```
|
|
|
|
## Policy Resolution
|
|
|
|
Stream-specific policies override wildcard:
|
|
|
|
```
|
|
Priority (highest to lowest):
|
|
1. Stream-specific policy (e.g., "orders")
|
|
2. Wildcard policy ("*")
|
|
3. No retention (keep forever)
|
|
```
|
|
|
|
## Example
|
|
|
|
```csharp
|
|
// Set default for all streams: 90 days
|
|
await _policyStore.SetPolicyAsync(new RetentionPolicyConfig
|
|
{
|
|
StreamName = "*",
|
|
MaxAge = TimeSpan.FromDays(90),
|
|
Enabled = true
|
|
});
|
|
|
|
// Override for audit logs: 7 years
|
|
await _policyStore.SetPolicyAsync(new RetentionPolicyConfig
|
|
{
|
|
StreamName = "audit-logs",
|
|
MaxAge = TimeSpan.FromDays(365 * 7),
|
|
Enabled = true
|
|
});
|
|
|
|
// Result:
|
|
// - "audit-logs": 7 years
|
|
// - "orders": 90 days (default)
|
|
// - "analytics": 90 days (default)
|
|
// - all other streams: 90 days (default)
|
|
```
|
|
|
|
## See Also
|
|
|
|
- [Retention Policies Overview](README.md)
|
|
- [Stream Configuration](../stream-configuration/retention-config.md)
|