Commit 7736b4df authored by Clint Mourlevat's avatar Clint Mourlevat

Fixing ticker service for first check

parent 6c3ec9b6
......@@ -19,7 +19,7 @@ namespace Stratis.Guru.Controllers
{
public class HomeController : Controller
{
private IMemoryCache _memoryCache;
private readonly IMemoryCache _memoryCache;
public HomeController(IMemoryCache memoryCache)
{
......
......@@ -20,13 +20,15 @@ namespace Stratis.Guru.Services
public Task StartAsync(CancellationToken cancellationToken)
{
var updateTimer = new System.Timers.Timer();
updateTimer.Interval = 10000;
updateTimer.Interval = 10;
updateTimer.Enabled = true;
updateTimer.Elapsed += (sender, args) =>
{
var coinmarketCapApiClient = new RestClient("https://api.coinmarketcap.com/v2/ticker/1343/");
var coinmarketCapApiRequest = new RestRequest(Method.GET);
var coinmarketcapApi = coinmarketCapApiClient.Execute(coinmarketCapApiRequest);
_memoryCache.Set("Coinmarketcap", coinmarketcapApi.Content);
updateTimer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds;
};
updateTimer.Start();
return Task.CompletedTask;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment