From dab9af45aa0d06b882c661fc3cddb6af6f61545e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 10 Sep 2022 17:37:33 -0500 Subject: add cache type --- src/slskd/Core/Options.cs | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 327036aa..2d561e29 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -200,7 +200,6 @@ namespace slskd /// Gets share options. /// [Validate] - [RequiresRestart] public SharesOptions Shares { get; init; } = new SharesOptions(); /// @@ -376,12 +375,26 @@ namespace slskd public string[] Filters { get; init; } = Array.Empty(); /// - /// Gets the type of storage to use for the share cache. + /// Share caching options. /// - [Argument(default, "share-cache-storage")] - [EnvironmentVariable("SHARE_CACHE_STORAGE")] - [Description("the type of storage to use for the cache")] - public StorageType CacheStorage { get; init; } = StorageType.Memory; + [Validate] + public ShareCacheOptions Cache { get; init; } = new ShareCacheOptions(); + + /// + /// Share caching options. + /// + public class ShareCacheOptions + { + /// + /// Gets the type of storage to use for the share cache. + /// + [Argument(default, "share-cache-storage-mode")] + [EnvironmentVariable("SHARE_CACHE_STORAGE_MODE")] + [Description("the type of storage to use for the cache")] + [Enum(typeof(StorageMode))] + [RequiresRestart] + public string StorageMode { get; init; } = slskd.StorageMode.Memory.ToString().ToLowerInvariant(); + } /// /// Extended validation. @@ -696,7 +709,7 @@ namespace slskd /// /// Filter options. /// - public class FiltersOptions : IValidatableObject + public class FiltersOptions { /// /// Gets search filter options. @@ -704,26 +717,6 @@ namespace slskd [Validate] public SearchOptions Search { get; init; } = new SearchOptions(); - /// - /// Extended validation. - /// - /// - /// - public IEnumerable Validate(ValidationContext validationContext) - { - var results = new List(); - - foreach (var filter in Share) - { - if (!filter.IsValidRegex()) - { - results.Add(new ValidationResult($"Share filter '{filter}' is not a valid regular expression")); - } - } - - return results; - } - /// /// Search filter options. /// -- cgit v1.2.3