Repository navigation
Expand file tree
/
Copy pathTestService2.cs
More file actions
47 lines (41 loc) · 1.47 KB
/
Copy pathTestService2.cs
File metadata and controls
47 lines (41 loc) · 1.47 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using log4net;
using Microsoft.Extensions.Caching.Distributed;
using StackExchange.Redis;
using StackExchange.Redis.Extensions.Core.Abstractions;
using WebApplicationTest.DAL;
using WebApplicationTest.Extension;
namespace WebApplicationTest.Services
{
[Authorized]
public class TestService2
{
public TestDbContext testDbContext { set; get; }
public ILog _logger { set; get; }
public IDistributedCache cache { set; get; }
public IRedisCacheClient redisCacheClient { set; get; }
public IRedisDatabase redisDatabase { set; get; }
public object x2()
{
_logger.Debug("TestService2---xxx22");
_logger.Warn("Warn");
redisDatabase.AddAsync("abc", "abc", TimeSpan.FromSeconds(100)).Wait();
var s = redisDatabase.Database.Sort("cities");
redisDatabase.Database.SortedSetAdd("cities", "a", 1.23, CommandFlags.None);
cache.SetString("key", "123", new DistributedCacheEntryOptions()
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(20)
});
return new
{
a = testDbContext.Xzqh2.Select(a => a),
b = testDbContext.Xzqhs.ToList(),
c = cache.GetString("key"),
d = redisDatabase.GetAsync<string>("abc").Result
};
}
}
}