wanshenmean
2026-03-17 94ad631d316da04c46266ddb1fc6e63e6f8f2fae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
namespace WIDESEAWCS_RedisService.Options
{
    public class RedisOptions
    {
        public bool Enabled { get; set; } = true;
 
        public string ConnectionString { get; set; } = "127.0.0.1:6379,defaultDatabase=0,connectTimeout=5000,abortConnect=false";
 
        public string InstanceName { get; set; } = "WIDESEAWCS:";
 
        public int DefaultDatabase { get; set; } = 0;
 
        public bool EnableSentinel { get; set; } = false;
 
        public string SentinelMasterName { get; set; } = "mymaster";
 
        public List<string> SentinelEndpoints { get; set; } = new();
 
        public int PoolSize { get; set; } = 10;
 
        public int ConnectRetry { get; set; } = 3;
 
        public string SerializerType { get; set; } = "Newtonsoft";
 
        public bool FallbackToMemory { get; set; } = true;
 
        public string KeyPrefix { get; set; } = "wcs:";
 
        /// <summary>
        /// 是否启用L1内存缓存层。禁用后只使用Redis,适用于需要外部修改Redis数据的场景
        /// </summary>
        public bool EnableL1Cache { get; set; } = true;
 
        /// <summary>
        /// 是否启用Redis到内存缓存的自动同步
        /// </summary>
        public bool EnableAutoSync { get; set; } = true;
 
        /// <summary>
        /// 自动同步间隔时间(秒),默认30秒
        /// </summary>
        public int SyncIntervalSeconds { get; set; } = 30;
 
        /// <summary>
        /// 同步时单次批量获取的Redis key数量上限,防止一次扫描过多key
        /// </summary>
        public int SyncBatchSize { get; set; } = 1000;
 
        /// <summary>
        /// 自动同步排除的key前缀列表(这些key不会被自动同步覆盖)
        /// 例如:["wcs:SocketDevices:"] 表示设备状态不会被自动同步
        /// </summary>
        public List<string> SyncExcludePrefixes { get; set; } = new();
 
        public MonitoringOptions Monitoring { get; set; } = new();
 
        public EvictionOptions Eviction { get; set; } = new();
    }
 
    public class MonitoringOptions
    {
        public bool Enabled { get; set; } = false;
 
        public int SlowLogThresholdMs { get; set; } = 100;
 
        public int HealthCheckIntervalSeconds { get; set; } = 30;
    }
 
    public class EvictionOptions
    {
        public int DefaultExpirationSeconds { get; set; } = 3600;
 
        public string MaxMemoryPolicy { get; set; } = "allkeys-lru";
    }
}