Store the user statistics for the performance.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user