Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
bltdc
DataCenter_Core2.1_20190520
Commits
63179558
Commit
63179558
authored
Aug 19, 2021
by
zhouminghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test Redis
parent
9c774e0c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
20 deletions
+32
-20
RedisHelper.cs
Bailun.DC.Common/RedisHelper.cs
+19
-19
FinanceController.cs
Bailun.DC.WebApi/Controllers/FinanceController.cs
+13
-1
No files found.
Bailun.DC.Common/RedisHelper.cs
View file @
63179558
...
...
@@ -8,7 +8,7 @@ namespace Bailun.DC.Common
{
public
class
RedisHelper
{
public
static
string
RedisServiceAddr
=
"
localhost
:6379"
;
public
static
string
RedisServiceAddr
=
"
127.0.0.1
:6379"
;
public
static
ConnectionMultiplexer
Redis
{
get
;
set
;
}
...
...
@@ -51,29 +51,29 @@ namespace Bailun.DC.Common
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public
static
bool
Add
<
T
>(
string
key
,
T
value
)
public
static
bool
Add
<
T
>(
string
key
,
T
value
,
TimeSpan
?
expire
=
null
)
{
using
(
var
conn
=
ConnectionMultiplexer
.
Connect
(
RedisServiceAddr
))
{
var
db
=
conn
.
GetDatabase
();
return
db
.
StringSet
(
key
,
JsonConvert
.
SerializeObject
(
value
));
}
}
/// <summary>
/// 添加(带过期时间)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="expire"></param>
/// <returns></returns>
public
static
bool
Add
<
T
>(
string
key
,
T
value
,
TimeSpan
expire
)
{
using
(
var
conn
=
ConnectionMultiplexer
.
Connect
(
RedisServiceAddr
))
{
var
db
=
conn
.
GetDatabase
();
return
db
.
StringSet
(
key
,
JsonConvert
.
SerializeObject
(
value
),
expire
);
return
db
.
StringSet
(
key
,
JsonConvert
.
SerializeObject
(
value
),
null
);
}
}
///// <summary>
///// 添加(带过期时间)
///// </summary>
///// <typeparam name="T"></typeparam>
///// <param name="key"></param>
///// <param name="value"></param>
///// <param name="expire"></param>
///// <returns></returns>
//public static bool Add<T>(string key, T value, TimeSpan expire)
//{
// using (var conn = ConnectionMultiplexer.Connect(RedisServiceAddr))
// {
// var db = conn.GetDatabase();
// return db.StringSet(key, JsonConvert.SerializeObject(value), expire);
// }
//}
}
}
Bailun.DC.WebApi/Controllers/FinanceController.cs
View file @
63179558
...
...
@@ -527,7 +527,19 @@ namespace Bailun.DC.WebApi.Controllers
[
HttpGet
(
"syncMonthSalesProfiOrderDetail"
)]
public
object
SyncMonthSalesProfiOrderDetail
(
DateTime
?
date
)
=>
new
FinanceService
().
SyncMonthSalesProfiOrderDetail
(
date
);
[
HttpGet
(
"testRedis"
)]
public
object
TestRedis
()
{
try
{
Bailun
.
DC
.
Common
.
RedisHelper
.
Add
(
"test0819"
,
"test add redis"
);
return
Bailun
.
DC
.
Common
.
RedisHelper
.
GetString
(
"test0819"
);
}
catch
(
Exception
e
)
{
return
e
.
Message
;
}
}
#
endregion
}
}
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