Skip to content

Commit

Permalink
Update SessionController.cs
Browse files Browse the repository at this point in the history
test controller added
  • Loading branch information
chsami committed May 18, 2024
1 parent b434301 commit 0c68825
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion MicrobotApi/Controllers/SessionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ public class SessionController : Controller
{
private readonly MicrobotContext _microbotContext;
private readonly IMemoryCache _memoryCache;
private readonly IConfiguration _configuration;
private readonly TimeSpan _cacheDuration = TimeSpan.FromMinutes(5);

public SessionController(MicrobotContext microbotContext, IMemoryCache memoryCache)
public SessionController(MicrobotContext microbotContext, IMemoryCache memoryCache, IConfiguration configuration)
{
_microbotContext = microbotContext;
_memoryCache = memoryCache;
_configuration = configuration;
}

[HttpGet("")]
Expand Down Expand Up @@ -75,6 +77,12 @@ public IActionResult CountLoggedIn()
return Ok(GetCachedLoggedInCount());
}

[HttpGet("count/test")]
public IActionResult Tester()
{
return Ok(_configuration.GetConnectionString("MicrobotContext"));
}

private int GetCachedCount()
{
if (!_memoryCache.TryGetValue("CachedCount", out int cachedData))
Expand Down

0 comments on commit 0c68825

Please sign in to comment.