Store the user statistics for the performance.

This commit is contained in:
Sébastien André
2021-08-11 22:37:14 +02:00
parent 6c53408c6d
commit 4c1dc89006
64 changed files with 453 additions and 1783 deletions

View File

@@ -9,27 +9,27 @@ namespace skydiveLogs_api.DomainBusiness
{
#region Public Methods
public bool Contains(CacheType type, int id = 0)
public bool Contains(CacheType type, int userId = 0)
{
var key = GetKey(id, type);
var key = GetKey(userId, type);
return MemoryCache.Default[key.ToString()] != null;
}
public void Delete(CacheType type, int id = 0)
public void Delete(CacheType type, int userId = 0)
{
var key = GetKey(id, type);
var key = GetKey(userId, type);
MemoryCache.Default.Remove(key.ToString());
}
public T Get<T>(CacheType type, int id = 0)
public T Get<T>(CacheType type, int userId = 0)
{
var key = GetKey(id, type);
var key = GetKey(userId, type);
return (T)MemoryCache.Default[key.ToString()];
}
public void Put(CacheType type, object value, int duration, int id = 0)
public void Put(CacheType type, object value, int duration, int userId = 0)
{
var key = GetKey(id, type);
var key = GetKey(userId, type);
if (duration <= 0)
throw new ArgumentException("Duration cannot be less or equal to zero", "duration");
@@ -41,9 +41,9 @@ namespace skydiveLogs_api.DomainBusiness
MemoryCache.Default.Set(key.ToString(), value, policy);
}
private string GetKey(int id, CacheType type)
private string GetKey(int userId, CacheType type)
{
return $"{id}-{type}";
return $"{userId}-{type}";
}
#endregion Public Methods