diff --git a/Zero.AntJob/Jobs/BuildProduct.cs b/Zero.AntJob/Jobs/BuildProduct.cs
index f503e37..426afd9 100644
--- a/Zero.AntJob/Jobs/BuildProduct.cs
+++ b/Zero.AntJob/Jobs/BuildProduct.cs
@@ -9,15 +9,15 @@ namespace Zero.AntJob.Jobs;
/// 定时创建产品
internal class BuildProduct : Handler
{
- private readonly ICache _cache;
+ private readonly ICacheProvider _cacheProvider;
- public BuildProduct(ICache cache)
+ public BuildProduct(ICacheProvider cacheProvider)
{
var job = Job;
job.Start = DateTime.Today;
job.Step = 15;
- _cache = cache;
+ _cacheProvider = cacheProvider;
}
protected override Int32 Execute(JobContext ctx)
@@ -39,7 +39,7 @@ protected override Int32 Execute(JobContext ctx)
};
// Redis去重
- if (!_cache.Add($"product:{pi.Name}", DateTime.Now)) pi.Name = Rand.NextString(8);
+ if (!_cacheProvider.Cache.Add($"product:{pi.Name}", DateTime.Now)) pi.Name = Rand.NextString(8);
list.Add(pi);
}
diff --git a/Zero.AntJob/Program.cs b/Zero.AntJob/Program.cs
index 6b285a6..e33decf 100644
--- a/Zero.AntJob/Program.cs
+++ b/Zero.AntJob/Program.cs
@@ -2,6 +2,7 @@
using AntJob.Providers;
using NewLife;
using NewLife.Caching;
+using NewLife.Caching.Services;
using NewLife.Log;
using Zero.AntJob;
using Zero.AntJob.Jobs;
@@ -15,10 +16,12 @@
{
// 配置星尘。借助StarAgent,或者读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust(null);
-
- // 配置缓存,使用 MemoryCache 或 Redis,其中Redis从配置中心读取配置信息
- var cache = new MemoryCache { Capacity = 1_000_000 };
- services.AddSingleton(cache);
+
+ // 默认内存缓存,如有配置RedisCache可使用Redis缓存
+ services.AddSingleton();
+
+ // 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+ //services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
// 注册服务
services.AddSingleton();
diff --git a/Zero.AntJob/Zero.AntJob.csproj b/Zero.AntJob/Zero.AntJob.csproj
index f6c6b15..f92711d 100644
--- a/Zero.AntJob/Zero.AntJob.csproj
+++ b/Zero.AntJob/Zero.AntJob.csproj
@@ -18,6 +18,14 @@
latest
+
+
+
+
+
+
+
+
diff --git a/Zero.AntJob/appsettings.json b/Zero.AntJob/appsettings.json
new file mode 100644
index 0000000..512a19b
--- /dev/null
+++ b/Zero.AntJob/appsettings.json
@@ -0,0 +1,21 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
+ "ConnectionStrings": {
+ "Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
+
+ // 各种数据库连接字符串模版,连接名Zero对应Zero.Data/Projects/Model.xml中的ConnName
+ //"Zero": "Server=.;Port=3306;Database=zero;Uid=root;Pwd=root;Provider=MySql",
+ //"Zero": "Data Source=.;Initial Catalog=zero;user=sa;password=sa;Provider=SqlServer",
+ //"Zero": "Server=.;Database=zero;Uid=root;Pwd=root;Provider=PostgreSql",
+ //"Zero": "Data Source=Tcp://127.0.0.1/ORCL;User Id=scott;Password=tiger;Provider=Oracle"
+ }
+}
diff --git a/Zero.Console/Program.cs b/Zero.Console/Program.cs
index 6f3384c..f9bc8cd 100644
--- a/Zero.Console/Program.cs
+++ b/Zero.Console/Program.cs
@@ -16,7 +16,7 @@
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust();
-// 缓存服务
+// 默认内存缓存,如有配置RedisCache可使用Redis缓存
services.AddSingleton();
// 初始化Redis、MQTT、RocketMQ,注册服务到容器
diff --git a/Zero.Console/appsettings.json b/Zero.Console/appsettings.json
index 16a0245..512a19b 100644
--- a/Zero.Console/appsettings.json
+++ b/Zero.Console/appsettings.json
@@ -7,7 +7,7 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
//"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.Desktop/ClientSetting.cs b/Zero.Desktop/ClientSetting.cs
index 2cc437d..93a68d3 100644
--- a/Zero.Desktop/ClientSetting.cs
+++ b/Zero.Desktop/ClientSetting.cs
@@ -28,7 +28,7 @@ public class ClientSetting : Config
#region 加载/保存
protected override void OnLoaded()
{
- if (Server.IsNullOrEmpty()) Server = "http://star.newlifex.com:6600";
+ if (Server.IsNullOrEmpty()) Server = "http://s.newlifex.com:6600";
base.OnLoaded();
}
diff --git a/Zero.Desktop/Program.cs b/Zero.Desktop/Program.cs
index 441b30c..adcf182 100644
--- a/Zero.Desktop/Program.cs
+++ b/Zero.Desktop/Program.cs
@@ -37,7 +37,8 @@ static void Main()
if (set.IsNew) "学无先后达者为师,欢迎使用新生命零代客户端!".SpeechTip();
- EntityFactory.InitAll();
+ // 预热数据层,执行自动建表等操作
+ _ = EntityFactory.InitAllAsync();
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
diff --git a/Zero.Desktop/appsettings.json b/Zero.Desktop/appsettings.json
index 598e7b0..ed9a074 100644
--- a/Zero.Desktop/appsettings.json
+++ b/Zero.Desktop/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Membership": "Data Source=..\\Data\\Membership.db;Provider=SQLite",
"Log": "Data Source=..\\Data\\Log.db;Provider=SQLite",
diff --git a/Zero.HttpServer/Program.cs b/Zero.HttpServer/Program.cs
index 6a478d0..b664c78 100644
--- a/Zero.HttpServer/Program.cs
+++ b/Zero.HttpServer/Program.cs
@@ -1,4 +1,6 @@
-using NewLife.Http;
+using NewLife.Caching.Services;
+using NewLife.Caching;
+using NewLife.Http;
using NewLife.Log;
using NewLife.Model;
using NewLife.Remoting;
@@ -13,6 +15,12 @@
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust();
+// 默认内存缓存,如有配置RedisCache可使用Redis缓存
+services.AddSingleton();
+
+// 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+//services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
+
var server = new HttpServer
{
Port = 8080,
diff --git a/Zero.HttpServer/Zero.HttpServer.csproj b/Zero.HttpServer/Zero.HttpServer.csproj
index b04cb80..cec7e66 100644
--- a/Zero.HttpServer/Zero.HttpServer.csproj
+++ b/Zero.HttpServer/Zero.HttpServer.csproj
@@ -20,6 +20,7 @@
+
diff --git a/Zero.HttpServer/appsettings.json b/Zero.HttpServer/appsettings.json
index b0e9df8..512a19b 100644
--- a/Zero.HttpServer/appsettings.json
+++ b/Zero.HttpServer/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.RpcServer/Program.cs b/Zero.RpcServer/Program.cs
index cc93b0f..486b507 100644
--- a/Zero.RpcServer/Program.cs
+++ b/Zero.RpcServer/Program.cs
@@ -1,4 +1,6 @@
using NewLife;
+using NewLife.Caching.Services;
+using NewLife.Caching;
using NewLife.Log;
using NewLife.Model;
using NewLife.Remoting;
@@ -13,6 +15,12 @@
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址、应用标识、密钥
var star = services.AddStardust();
+// 默认内存缓存,如有配置RedisCache可使用Redis缓存
+services.AddSingleton();
+
+// 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+//services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
+
// 实例化RPC服务端,指定端口,同时在Tcp/Udp/IPv4/IPv6上监听
var server = new ApiServer(12346)
{
diff --git a/Zero.RpcServer/Zero.RpcServer.csproj b/Zero.RpcServer/Zero.RpcServer.csproj
index f0467f5..e731511 100644
--- a/Zero.RpcServer/Zero.RpcServer.csproj
+++ b/Zero.RpcServer/Zero.RpcServer.csproj
@@ -21,6 +21,7 @@
+
diff --git a/Zero.RpcServer/appsettings.json b/Zero.RpcServer/appsettings.json
index b0e9df8..512a19b 100644
--- a/Zero.RpcServer/appsettings.json
+++ b/Zero.RpcServer/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.Server/Program.cs b/Zero.Server/Program.cs
index 6d82906..e84a031 100644
--- a/Zero.Server/Program.cs
+++ b/Zero.Server/Program.cs
@@ -1,7 +1,10 @@
using System;
using NewLife;
using NewLife.Agent;
+using NewLife.Caching.Services;
+using NewLife.Caching;
using NewLife.Log;
+using NewLife.Model;
using NewLife.Net;
using NewLife.Remoting;
using NewLife.Threading;
@@ -11,13 +14,29 @@ namespace Zero.Server;
internal class Program
{
- private static void Main(String[] args) => new MyServices().Main(args);
+ private static void Main(String[] args)
+ {
+ // 初始化对象容器,提供注入能力
+ var services = ObjectContainer.Current;
+ services.AddSingleton(XTrace.Log);
+
+ // 配置星尘。自动读取配置文件 config/star.config 中的服务器地址
+ var star = services.AddStardust();
+
+ // 默认内存缓存,如有配置RedisCache可使用Redis缓存
+ services.AddSingleton();
+
+ var svc = new MyServices { ServiceProvider = services.BuildServiceProvider() };
+ svc.Main(args);
+ }
}
/// 代理服务例子。自定义服务程序可参照该类实现。
public class MyServices : ServiceBase
{
#region 属性
+ public IServiceProvider ServiceProvider { get; set; }
+
/// 性能跟踪器
public ITracer Tracer { get; set; }
@@ -44,7 +63,7 @@ public MyServices()
protected override void StartWork(String reason)
{
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址、应用标识、密钥
- _star = new StarFactory();
+ _star = ServiceProvider.GetService();
Tracer = _star.Tracer;
InitNetServer();
diff --git a/Zero.Server/Zero.Server.csproj b/Zero.Server/Zero.Server.csproj
index bc8fca1..86410b9 100644
--- a/Zero.Server/Zero.Server.csproj
+++ b/Zero.Server/Zero.Server.csproj
@@ -21,6 +21,7 @@
+
diff --git a/Zero.Server/appsettings.json b/Zero.Server/appsettings.json
index b0e9df8..512a19b 100644
--- a/Zero.Server/appsettings.json
+++ b/Zero.Server/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.TcpServer/Program.cs b/Zero.TcpServer/Program.cs
index ce3c456..454f67c 100644
--- a/Zero.TcpServer/Program.cs
+++ b/Zero.TcpServer/Program.cs
@@ -1,5 +1,7 @@
using System.Net.Sockets;
using NewLife;
+using NewLife.Caching.Services;
+using NewLife.Caching;
using NewLife.Log;
using NewLife.Model;
using Stardust;
@@ -20,14 +22,23 @@ private static async Task Main(String[] args)
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址、应用标识、密钥
var star = services.AddStardust();
+ // 默认内存缓存,如有配置RedisCache可使用Redis缓存
+ services.AddSingleton();
+
+ // 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+ //services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
+
+ // 注入消息处理器,可注入多个
services.AddTransient();
- //var provider = services.BuildServiceProvider();
+ var provider = services.BuildServiceProvider();
// 实例化网络服务端,指定端口,同时在Tcp/Udp/IPv4/IPv6上监听
var server = new MyNetServer
{
Port = 12345,
+ ServiceProvider = provider,
+
Log = XTrace.Log,
SessionLog = XTrace.Log,
Tracer = star?.Tracer,
diff --git a/Zero.TcpServer/Zero.TcpServer.csproj b/Zero.TcpServer/Zero.TcpServer.csproj
index 5534f00..fd71432 100644
--- a/Zero.TcpServer/Zero.TcpServer.csproj
+++ b/Zero.TcpServer/Zero.TcpServer.csproj
@@ -21,6 +21,7 @@
+
diff --git a/Zero.TcpServer/appsettings.json b/Zero.TcpServer/appsettings.json
index b0e9df8..512a19b 100644
--- a/Zero.TcpServer/appsettings.json
+++ b/Zero.TcpServer/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.Web/Program.cs b/Zero.Web/Program.cs
index 9f66720..7745dd1 100644
--- a/Zero.Web/Program.cs
+++ b/Zero.Web/Program.cs
@@ -1,5 +1,5 @@
-using NewLife;
-using NewLife.Caching;
+using NewLife.Caching;
+using NewLife.Caching.Services;
using NewLife.Cube;
using NewLife.Log;
using XCode;
@@ -19,15 +19,11 @@
// 配置星尘。借助StarAgent,或者读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust(null);
-// 启用星尘配置中心。分布式部署或容器化部署推荐使用,单机部署不推荐使用
-var config = star.Config;
+// 默认内存缓存,如有配置RedisCache可使用Redis缓存
+services.AddSingleton();
-// 默认内存缓存,如有配置可使用Redis缓存
-var cache = new MemoryCache();
-if (config != null && !config["redisCache"].IsNullOrEmpty())
- services.AddSingleton(p => new FullRedis(p, "redisCache") { Name = "Cache", Tracer = star.Tracer });
-else
- services.AddSingleton(cache);
+// 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+//services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
// 启用接口响应压缩
services.AddResponseCompression();
@@ -44,10 +40,6 @@
var app = builder.Build();
-// 预热数据层,执行自动建表等操作
-// 连接名 Zero 对应连接字符串名字,同时也对应 Zero.Data/Projects/Model.xml 头部的 ConnName
-EntityFactory.InitConnection("Zero");
-
// 使用Cube前添加自己的管道
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
diff --git a/Zero.Web/appsettings.json b/Zero.Web/appsettings.json
index 57813fe..c67c14c 100644
--- a/Zero.Web/appsettings.json
+++ b/Zero.Web/appsettings.json
@@ -8,7 +8,8 @@
},
"AllowedHosts": "*",
"Urls": "http://*:6000;https://*:6001",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite",
"Membership": "Data Source=..\\Data\\Membership.db;Provider=SQLite",
diff --git a/Zero.WebApi/Program.cs b/Zero.WebApi/Program.cs
index 0280dab..b6073fd 100644
--- a/Zero.WebApi/Program.cs
+++ b/Zero.WebApi/Program.cs
@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Mvc;
using NewLife;
using NewLife.Caching;
+using NewLife.Caching.Services;
using NewLife.Log;
using NewLife.Serialization;
using XCode;
@@ -23,22 +24,11 @@
// 配置星尘。借助StarAgent,或者读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust(null);
-{
- // 启用星尘配置中心。分布式部署或容器化部署推荐使用,单机部署不推荐使用
- var config = star.Config;
-
- // 默认内存缓存,如有配置可使用Redis缓存
- var cache = new MemoryCache();
- if (config != null && !config["redisCache"].IsNullOrEmpty())
- services.AddSingleton(p => new FullRedis(p, "redisCache") { Name = "Cache" });
- else
- services.AddSingleton(cache);
-}
+// 默认内存缓存,如有配置RedisCache可使用Redis缓存
+services.AddSingleton();
-{
- // 引入Redis,用于消息队列和缓存,单例,带性能跟踪
- services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
-}
+// 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+//services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
var set = ApiSetting.Current;
services.AddSingleton(set);
@@ -75,8 +65,7 @@
var app = builder.Build();
// 预热数据层,执行自动建表等操作
-// 连接名 Zero 对应连接字符串名字,同时也对应 Zero.Data/Projects/Model.xml 头部的 ConnName
-EntityFactory.InitConnection("Zero");
+_ = EntityFactory.InitAllAsync();
app.UseResponseCompression();
diff --git a/Zero.WebApi/Services/NodeService.cs b/Zero.WebApi/Services/NodeService.cs
index b51f721..459e6e5 100644
--- a/Zero.WebApi/Services/NodeService.cs
+++ b/Zero.WebApi/Services/NodeService.cs
@@ -12,7 +12,9 @@ namespace Zero.WebApi.Services;
public class NodeService
{
- private static readonly ICache _cache = new MemoryCache();
+ private readonly ICacheProvider _cacheProvider;
+
+ public NodeService(ICacheProvider cacheProvider) => _cacheProvider = cacheProvider;
#region 注册&登录
public Boolean Auth(Node node, LoginInfo inf, String ip, String secret)
@@ -81,7 +83,7 @@ public NodeOnline Logout(Node node, String reason, String ip)
online.Delete();
var sid = $"{node.ID}@{ip}";
- _cache.Remove($"NodeOnline:{sid}");
+ _cacheProvider.Cache.Remove($"NodeOnline:{sid}");
// 计算在线时长
if (online.CreateTime.Year > 2000)
@@ -250,10 +252,10 @@ public PingResponse Ping(Node node, PingInfo inf, String token, String ip, ApiSe
public NodeOnline GetOnline(Node node, String ip)
{
var sid = $"{node.ID}@{ip}";
- var olt = _cache.Get($"NodeOnline:{sid}");
+ var olt = _cacheProvider.Cache.Get($"NodeOnline:{sid}");
if (olt != null)
{
- _cache.SetExpire($"NodeOnline:{sid}", TimeSpan.FromSeconds(600));
+ _cacheProvider.Cache.SetExpire($"NodeOnline:{sid}", TimeSpan.FromSeconds(600));
return olt;
}
@@ -284,7 +286,7 @@ public NodeOnline CreateOnline(Node node, String token, String ip)
olt.Creator = Environment.MachineName;
- _cache.Set($"NodeOnline:{sid}", olt, 600);
+ _cacheProvider.Cache.Set($"NodeOnline:{sid}", olt, 600);
return olt;
}
diff --git a/Zero.WebApi/appsettings.json b/Zero.WebApi/appsettings.json
index 4a88389..1beadd3 100644
--- a/Zero.WebApi/appsettings.json
+++ b/Zero.WebApi/appsettings.json
@@ -8,7 +8,8 @@
},
"AllowedHosts": "*",
"Urls": "http://*:6100;https://*:6101",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.WebSocketServer/Program.cs b/Zero.WebSocketServer/Program.cs
index 955fb72..b72bdef 100644
--- a/Zero.WebSocketServer/Program.cs
+++ b/Zero.WebSocketServer/Program.cs
@@ -1,6 +1,5 @@
-using System.Net.WebSockets;
-using NewLife;
-using NewLife.Data;
+using NewLife.Caching;
+using NewLife.Caching.Services;
using NewLife.Http;
using NewLife.Log;
using NewLife.Model;
@@ -14,6 +13,12 @@
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust();
+// 默认内存缓存,如有配置RedisCache可使用Redis缓存
+services.AddSingleton();
+
+// 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+//services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
+
var server = new HttpServer
{
Port = 8081,
diff --git a/Zero.WebSocketServer/Zero.WebSocketServer.csproj b/Zero.WebSocketServer/Zero.WebSocketServer.csproj
index 13925f2..80297b4 100644
--- a/Zero.WebSocketServer/Zero.WebSocketServer.csproj
+++ b/Zero.WebSocketServer/Zero.WebSocketServer.csproj
@@ -22,6 +22,7 @@
+
diff --git a/Zero.WebSocketServer/appsettings.json b/Zero.WebSocketServer/appsettings.json
index b0e9df8..512a19b 100644
--- a/Zero.WebSocketServer/appsettings.json
+++ b/Zero.WebSocketServer/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"
diff --git a/Zero.Worker/Program.cs b/Zero.Worker/Program.cs
index 2efcf5d..a2765f2 100644
--- a/Zero.Worker/Program.cs
+++ b/Zero.Worker/Program.cs
@@ -19,11 +19,11 @@
// 配置星尘。借助StarAgent,或者读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust(null);
- // 默认内存缓存,如有配置可使用Redis缓存
+ // 默认内存缓存,如有配置RedisCache可使用Redis缓存
services.AddSingleton();
- // 引入Redis,用于消息队列和缓存,单例,带性能跟踪
- services.AddRedis("127.0.0.1:6379", "123456", 3, 5000);
+ // 引入Redis,用于消息队列和缓存,单例,带性能跟踪。一般使用上面的ICacheProvider替代
+ services.AddRedis("127.0.0.1:6379", "", 3, 5000);
// 注册后台服务
services.AddHostedService();
diff --git a/Zero.Worker/appsettings.json b/Zero.Worker/appsettings.json
index b0e9df8..512a19b 100644
--- a/Zero.Worker/appsettings.json
+++ b/Zero.Worker/appsettings.json
@@ -7,7 +7,8 @@
}
},
"AllowedHosts": "*",
- //"StarServer": "http://star.newlifex.com:6600",
+ //"StarServer": "http://s.newlifex.com:6600",
+ //"RedisCache": "server=127.0.0.1:6379;password=;db=3",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"