Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RedisLab
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李福茂
RedisLab
Commits
b093ddf5
Commit
b093ddf5
authored
Nov 16, 2021
by
Fumao Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
93f1a89e
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
300 additions
and
46 deletions
+300
-46
.editorconfig
.editorconfig
+4
-0
MatrixOne.RedisLab.sln
MatrixOne.RedisLab.sln
+3
-3
Counter.razor
MatrixOne.RedisLab/Client/Pages/Counter.razor
+0
-16
FetchData.razor
MatrixOne.RedisLab/Client/Pages/FetchData.razor
+1
-1
Logs.razor
MatrixOne.RedisLab/Client/Pages/Logs.razor
+46
-0
Redis.razor
MatrixOne.RedisLab/Client/Pages/Redis.razor
+41
-0
MainLayout.razor
MatrixOne.RedisLab/Client/Shared/MainLayout.razor
+1
-1
NavMenu.razor
MatrixOne.RedisLab/Client/Shared/NavMenu.razor
+5
-5
RedisController.cs
MatrixOne.RedisLab/Server/Controllers/RedisController.cs
+76
-0
MatrixOne.RedisLab.Server.csproj
MatrixOne.RedisLab/Server/MatrixOne.RedisLab.Server.csproj
+1
-0
Startup.cs
MatrixOne.RedisLab/Server/Startup.cs
+3
-0
11-15-16-20.log
MatrixOne.RedisLab/Server/logs/11-15-16-20.log
+0
-1
11-15-16-50.log
MatrixOne.RedisLab/Server/logs/11-15-16-50.log
+0
-2
11-15-16-55.log
MatrixOne.RedisLab/Server/logs/11-15-16-55.log
+0
-1
11-15-17-0.log
MatrixOne.RedisLab/Server/logs/11-15-17-0.log
+0
-6
11-15-17-10.log
MatrixOne.RedisLab/Server/logs/11-15-17-10.log
+0
-3
11-15-17-15.log
MatrixOne.RedisLab/Server/logs/11-15-17-15.log
+0
-3
11-15-17-5.log
MatrixOne.RedisLab/Server/logs/11-15-17-5.log
+0
-4
MatrixOne.RedisLab.Shared.csproj
MatrixOne.RedisLab/Shared/MatrixOne.RedisLab.Shared.csproj
+3
-0
RedisKey.cs
MatrixOne.RedisLab/Shared/RedisKey.cs
+10
-0
RedisService.cs
MatrixOne.RedisLab/Shared/services/RedisService.cs
+106
-0
No files found.
.editorconfig
0 → 100644
View file @
b093ddf5
[*.cs]
# CS1591: 缺少对公共可见类型或成员的 XML 注释
dotnet_diagnostic.CS1591.severity = silent
MatrixOne.RedisLab.sln
View file @
b093ddf5
...
...
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31829.152
MinimumVisualStudioVersion = 10.0.40219.1
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "MatrixOne.RedisLab.Server", "MatrixOne.RedisLab\Server\MatrixOne.RedisLab.Server.csproj", "{E74DC0BB-70C0-4180-8747-6169787D4BCA}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "MatrixOne.RedisLab.Server", "MatrixOne.RedisLab\Server\MatrixOne.RedisLab.Server.csproj", "{E74DC0BB-70C0-4180-8747-6169787D4BCA}"
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "MatrixOne.RedisLab.Client", "MatrixOne.RedisLab\Client\MatrixOne.RedisLab.Client.csproj", "{389886B7-5EDF-4F6F-AB6D-F18586F56D66}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "MatrixOne.RedisLab.Client", "MatrixOne.RedisLab\Client\MatrixOne.RedisLab.Client.csproj", "{389886B7-5EDF-4F6F-AB6D-F18586F56D66}"
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "MatrixOne.RedisLab.Shared", "MatrixOne.RedisLab\Shared\MatrixOne.RedisLab.Shared.csproj", "{0EE6723E-4EDC-4601-B544-7DB57CF5DE61}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "MatrixOne.RedisLab.Shared", "MatrixOne.RedisLab\Shared\MatrixOne.RedisLab.Shared.csproj", "{0EE6723E-4EDC-4601-B544-7DB57CF5DE61}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{33A9AF30-A10D-4770-9CCF-92812F6E6B03}"
ProjectSection(SolutionItems) = preProject
...
...
MatrixOne.RedisLab/Client/Pages/Counter.razor
deleted
100644 → 0
View file @
93f1a89e
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
MatrixOne.RedisLab/Client/Pages/FetchData.razor
View file @
b093ddf5
...
...
@@ -40,7 +40,7 @@ else
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("
api/
WeatherForecast");
}
}
MatrixOne.RedisLab/Client/Pages/Logs.razor
0 → 100644
View file @
b093ddf5
@page "/logs"
@using MatrixOne.RedisLab.Shared
@inject HttpClient Http
<h1>Logs</h1>
@if (logpack == null)
{
<p><em>Loading...</em></p>
}
else
{
<h3>File:@logpack.file</h3>
<table class="table">
<thead>
<tr>
<th>id</th>
<th>time</th>
<th>level</th>
<th>message</th>
</tr>
</thead>
<tbody>
@foreach (var log in logpack.Logs)
{
<tr>
<td>@log.id</td>
<td>@log.time.ToLongTimeString()</td>
<td>@log.level</td>
<td>@log.message</td>
</tr>
}
</tbody>
</table>
}
@code {
private LogPack logpack;
protected override async Task OnInitializedAsync()
{
logpack = await Http.GetFromJsonAsync<LogPack>("api/Log/GetLastLog");
}
}
MatrixOne.RedisLab/Client/Pages/Redis.razor
0 → 100644
View file @
b093ddf5
@page "/redis"
@using MatrixOne.RedisLab.Shared
@inject HttpClient Http
<h1>Redis</h1>
@if (keys == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>key</th>
<th>type</th>
</tr>
</thead>
<tbody>
@foreach (var key in keys)
{
<tr>
<td>@key.Name</td>
<td>@key.Type</td>
</tr>
}
</tbody>
</table>
}
@code {
private RedisKey[] keys;
protected override async Task OnInitializedAsync()
{
keys = await Http.GetFromJsonAsync<RedisKey[]>("api/Redis/LoadKeys");
}
}
MatrixOne.RedisLab/Client/Shared/MainLayout.razor
View file @
b093ddf5
...
...
@@ -6,7 +6,7 @@
<div class="main">
<div class="top-row px-4">
<a href="
http://blazor.net" target="_blank" class="ml-md-auto">About
</a>
<a href="
/swagger/" target="_blank" class="ml-md-auto">Swagger
</a>
</div>
<div class="content px-4">
...
...
MatrixOne.RedisLab/Client/Shared/NavMenu.razor
View file @
b093ddf5
...
...
@@ -13,13 +13,13 @@
</NavLink>
</li>
<li class="nav-item px-3">
<
a href="/swagger/" target="_blank" class="nav-link
">
<span class="oi oi-
arrow-right" aria-hidden="true"></span> Swagger
</
a
>
<
NavLink class="nav-link" href="logs
">
<span class="oi oi-
bug" aria-hidden="true"></span> Logs
</
NavLink
>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="
counter
">
<span class="oi oi-plus" aria-hidden="true"></span>
Counter
<NavLink class="nav-link" href="
redis
">
<span class="oi oi-plus" aria-hidden="true"></span>
Redis
</NavLink>
</li>
<li class="nav-item px-3">
...
...
MatrixOne.RedisLab/Server/Controllers/RedisController.cs
0 → 100644
View file @
b093ddf5
using
CSRedis
;
using
MatrixOne.RedisLab.Shared
;
using
MatrixOne.RedisLab.Shared.services
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
MatrixOne.RedisLab.Server.Controllers
{
[
ApiController
]
[
Route
(
"api/[controller]"
)]
public
class
RedisController
:
ControllerBase
{
private
readonly
ILogger
<
RedisController
>
logger
;
private
readonly
RedisService
redis
;
public
RedisController
(
ILogger
<
RedisController
>
logger
,
RedisService
redis
)
{
this
.
logger
=
logger
;
this
.
redis
=
redis
;
}
[
HttpGet
(
"LoadKeys"
)]
public
async
Task
<
RedisKey
[
]>
LoadKeys
(
string
pattern
=
"*"
)
{
List
<
RedisKey
>
ret
=
new
List
<
RedisKey
>();
string
[]
keys
=
await
redis
.
GetKeys
(
pattern
);
foreach
(
var
key
in
keys
)
{
RedisKey
info
=
new
RedisKey
{
Name
=
key
,
Type
=
await
redis
.
GetKeyType
(
key
)
};
ret
.
Add
(
info
);
}
return
ret
.
ToArray
();
}
[
HttpDelete
(
"DelKeys"
)]
public
async
Task
<
long
>
DelKeys
(
string
key
)
{
return
await
redis
.
DelKeys
(
key
);
}
[
HttpGet
(
"GetKeyType"
)]
public
async
Task
<
KeyType
>
GetKeyType
(
string
key
)
{
KeyType
ret
=
await
redis
.
GetKeyType
(
key
);
return
ret
;
}
[
HttpGet
(
"GetKeyValue"
)]
public
async
Task
<
object
>
GetKeyValue
(
string
key
,
long
cursor
=
0
,
long
start
=
0
,
long
len
=
0
)
{
object
ret
=
null
;
ret
=
await
redis
.
GetKeyValue
(
key
,
cursor
,
start
,
len
);
return
ret
;
}
[
HttpPost
(
"SetKeyValue"
)]
public
async
Task
<
bool
>
SetKeyValue
(
string
key
,
object
value
)
{
return
await
redis
.
SetKeyValue
(
key
,
value
);
}
}
}
MatrixOne.RedisLab/Server/MatrixOne.RedisLab.Server.csproj
View file @
b093ddf5
...
...
@@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.6.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
...
...
MatrixOne.RedisLab/Server/Startup.cs
View file @
b093ddf5
using
MatrixOne.RedisLab.Shared.services
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.ResponseCompression
;
...
...
@@ -49,6 +51,7 @@ namespace MatrixOne.RedisLab.Server
services
.
AddRazorPages
();
services
.
AddSingleton
<
RedisService
>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
MatrixOne.RedisLab/Server/logs/11-15-16-20.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 16:22:46.0517", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Server/logs/11-15-16-50.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 16:50:49.3349", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 16:52:30.0571", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Server/logs/11-15-16-55.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 16:58:08.0180", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Server/logs/11-15-17-0.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 17:02:41.3973", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 17:03:56.8854", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "2", "time": "2021-11-15 17:04:13.0705", "level": "INFO", "message": "swagger\u8def\u5f84:http:\/\/localhost:5000\/swagger" }
{ "id": "1", "time": "2021-11-15 17:04:26.7151", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "2", "time": "2021-11-15 17:04:36.0590", "level": "INFO", "message": "swagger\u8def\u5f84:http:\/\/localhost:5000\/swagger" }
{ "id": "1", "time": "2021-11-15 17:19:21.0740", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Server/logs/11-15-17-10.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 17:12:17.9362", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 17:13:20.7245", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 17:14:42.8431", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Server/logs/11-15-17-15.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 17:16:12.3898", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 17:17:08.5785", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 17:18:17.4340", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Server/logs/11-15-17-5.log
deleted
100644 → 0
View file @
93f1a89e
{ "id": "1", "time": "2021-11-15 17:07:46.6727", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "2", "time": "2021-11-15 17:08:03.5041", "level": "INFO", "message": "swagger\u8def\u5f84:http:\/\/localhost:5000\/swagger" }
{ "id": "1", "time": "2021-11-15 17:09:04.2050", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
{ "id": "1", "time": "2021-11-15 17:09:53.3218", "level": "INFO", "message": "\u65e5\u5fd7\u5f00\u59cb" }
MatrixOne.RedisLab/Shared/MatrixOne.RedisLab.Shared.csproj
View file @
b093ddf5
...
...
@@ -5,6 +5,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.6.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="NLog" Version="4.7.12" />
</ItemGroup>
...
...
MatrixOne.RedisLab/Shared/RedisKey.cs
0 → 100644
View file @
b093ddf5
using
CSRedis
;
namespace
MatrixOne.RedisLab.Shared
{
public
class
RedisKey
{
public
string
Name
{
get
;
set
;
}
public
KeyType
Type
{
get
;
set
;
}
}
}
MatrixOne.RedisLab/Shared/services/RedisService.cs
0 → 100644
View file @
b093ddf5
using
CSRedis
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
MatrixOne.RedisLab.Shared.services
{
/// <summary>
/// Redis连接信息对象实体
/// </summary>
public
class
ConnectionInfo
{
/// <summary>
/// Redis名称,用来标识不同的Redis地址,不能重复
/// </summary>
public
string
Key
{
get
;
set
;
}
/// <summary>
/// 连接信息,参见json配置信息
/// </summary>
public
string
Connection
{
get
;
set
;
}
/// <summary>
/// 密码
/// </summary>
public
string
Password
{
get
;
set
;
}
}
public
class
RedisService
{
private
readonly
CSRedisClient
_client
;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="options"></param>
public
RedisService
(
ILogger
<
RedisService
>
logger
)
{
logger
.
LogInformation
(
"============开始初始化Redis连接=================="
);
string
con
=
"172.18.0.230:6379"
;
string
psw
=
"MDNcVb924a"
;
Stopwatch
watch
=
new
Stopwatch
();
watch
.
Start
();
_client
=
new
CSRedisClient
(
$"
{
con
}
,password=
{
psw
}
"
);
watch
.
Stop
();
logger
.
LogInformation
(
$"Redis 连接耗时(毫秒) =
{
watch
.
ElapsedMilliseconds
}
"
);
watch
.
Reset
();
logger
.
LogInformation
(
"============Redis连接完成=================="
);
}
public
async
Task
<
string
[
]>
GetKeys
(
string
pattern
=
"*"
)
{
string
[]
ret
=
await
_client
.
KeysAsync
(
pattern
);
return
ret
;
}
public
async
Task
<
long
>
DelKeys
(
string
key
)
{
return
await
_client
.
DelAsync
(
key
);
}
public
async
Task
<
KeyType
>
GetKeyType
(
string
key
)
{
KeyType
ret
=
await
_client
.
TypeAsync
(
key
);
return
ret
;
}
public
async
Task
<
object
>
GetKeyValue
(
string
key
,
long
cursor
=
0
,
long
start
=
0
,
long
len
=
0
)
{
object
ret
=
null
;
switch
(
await
_client
.
TypeAsync
(
key
))
{
default
:
case
KeyType
.
None
:
case
KeyType
.
String
:
ret
=
await
_client
.
GetAsync
(
key
);
break
;
case
KeyType
.
List
:
ret
=
await
_client
.
LRangeAsync
(
key
,
start
,
start
+
len
);
break
;
case
KeyType
.
Set
:
ret
=
await
_client
.
SScanAsync
(
key
,
cursor
,
"*"
,
len
);
break
;
case
KeyType
.
ZSet
:
ret
=
await
_client
.
ZScanAsync
(
key
,
cursor
,
"*"
,
len
);
break
;
case
KeyType
.
Hash
:
ret
=
await
_client
.
HScanAsync
(
key
,
cursor
,
"*"
,
len
);
break
;
case
KeyType
.
Stream
:
ret
=
_client
.
XRange
(
key
,
start
.
ToString
(),
"+"
,
len
);
break
;
}
return
ret
;
}
public
async
Task
<
bool
>
SetKeyValue
(
string
key
,
object
value
)
{
return
await
_client
.
SetAsync
(
key
,
value
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment