|
@@ -13,6 +13,8 @@ using log4net.Config;
|
13
|
13
|
using Microsoft.Extensions.Configuration;
|
14
|
14
|
using Microsoft.Extensions.Configuration.FileExtensions;
|
15
|
15
|
using Microsoft.Extensions.Configuration.Json;
|
|
16
|
+using ServiceStack.Redis;
|
|
17
|
+using ServiceStack.Redis.Generic;
|
16
|
18
|
|
17
|
19
|
namespace AuctionTracker
|
18
|
20
|
{
|
|
@@ -25,6 +27,7 @@ namespace AuctionTracker
|
25
|
27
|
private static IConfiguration _configuration;
|
26
|
28
|
private static ILog _logger;
|
27
|
29
|
|
|
30
|
+ private static RedisManagerPool _redisPool;
|
28
|
31
|
private static string _character;
|
29
|
32
|
private static string _locale;
|
30
|
33
|
private static string _realm;
|
|
@@ -80,6 +83,26 @@ namespace AuctionTracker
|
80
|
83
|
}
|
81
|
84
|
}
|
82
|
85
|
lastAuctions = auctions;
|
|
86
|
+ //update redis database
|
|
87
|
+ using (IRedisClient client = _redisPool.GetClient())
|
|
88
|
+ {
|
|
89
|
+ var auctionClient = client.As<RedisAuctionSnapshot>();
|
|
90
|
+ foreach(Auction auction in auctions)
|
|
91
|
+ {
|
|
92
|
+ RedisAuctionSnapshot snapshot = await RedisAuctionSnapshot.FromAuctionClientAsync(auction, _client, _locale);
|
|
93
|
+ auctionClient.Store(snapshot, TimeSpan.FromMinutes(20d));
|
|
94
|
+ }
|
|
95
|
+ }
|
|
96
|
+ //retrieving stuff
|
|
97
|
+ _logger.Info("Retrieving stored values");
|
|
98
|
+ using (IRedisClient client = _redisPool.GetClient())
|
|
99
|
+ {
|
|
100
|
+ var auctionClient = client.As<RedisAuctionSnapshot>();
|
|
101
|
+ foreach(RedisAuctionSnapshot item in auctionClient.GetAll())
|
|
102
|
+ {
|
|
103
|
+ _logger.Info(item.Name);
|
|
104
|
+ }
|
|
105
|
+ }
|
83
|
106
|
}
|
84
|
107
|
static async Task Main(string[] args)
|
85
|
108
|
{
|
|
@@ -99,6 +122,8 @@ namespace AuctionTracker
|
99
|
122
|
_logger.Info("Creating Clients");
|
100
|
123
|
_client = new BlizzSharpClient($"{_configuration["blizzardApiKey"]}");
|
101
|
124
|
_pushClient = new PushClient($"{_configuration["pushoverSecretKey"]}", $"{_configuration["pushoverUserKey"]}");
|
|
125
|
+ _logger.Info("Initializing redis pool");
|
|
126
|
+ _redisPool = new RedisManagerPool("localhost:6379");
|
102
|
127
|
_logger.Info("AuctionTracker started, entering loop");
|
103
|
128
|
|
104
|
129
|
while(true)
|