Add an endpoint to call the lof of jumps by page.
This commit is contained in:
@@ -7,24 +7,39 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
public class CacheService : ICacheService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public CacheService()
|
||||
{
|
||||
_memoryCache = MemoryCache.Default;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly MemoryCache _memoryCache;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool Contains(CacheType type, int userId = 0)
|
||||
{
|
||||
var key = GetKey(userId, type);
|
||||
return MemoryCache.Default[key.ToString()] != null;
|
||||
return _memoryCache.Contains(key.ToString());
|
||||
}
|
||||
|
||||
public void Delete(CacheType type, int userId = 0)
|
||||
{
|
||||
var key = GetKey(userId, type);
|
||||
MemoryCache.Default.Remove(key.ToString());
|
||||
_memoryCache.Remove(key.ToString());
|
||||
}
|
||||
|
||||
public T Get<T>(CacheType type, int userId = 0)
|
||||
{
|
||||
var key = GetKey(userId, type);
|
||||
return (T)MemoryCache.Default[key.ToString()];
|
||||
return (T)_memoryCache.Get(key.ToString());
|
||||
}
|
||||
|
||||
public void Put(CacheType type, object value, int duration, int userId = 0)
|
||||
@@ -38,7 +53,7 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
AbsoluteExpiration = DateTime.Now.AddMilliseconds(duration)
|
||||
};
|
||||
|
||||
MemoryCache.Default.Set(key.ToString(), value, policy);
|
||||
_memoryCache.Set(key.ToString(), value, policy);
|
||||
}
|
||||
|
||||
private string GetKey(int userId, CacheType type)
|
||||
|
||||
@@ -19,6 +19,10 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
||||
|
||||
Jump GetJumpById(int id);
|
||||
|
||||
int GetJumpCount();
|
||||
|
||||
IEnumerable<Jump> GetJumpsByIndexes(int beginIndex, int endIndex);
|
||||
|
||||
void UpdateJump(int id, Jump jump);
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -63,6 +63,16 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
return _jumpRepository.GetById(id);
|
||||
}
|
||||
|
||||
public int GetJumpCount()
|
||||
{
|
||||
return _jumpRepository.GetCount(_identityService.ConnectedUser);
|
||||
}
|
||||
|
||||
public IEnumerable<Jump> GetJumpsByIndexes(int beginIndex, int endIndex)
|
||||
{
|
||||
return _jumpRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
|
||||
}
|
||||
|
||||
public void UpdateJump(int id, Jump updatedJump)
|
||||
{
|
||||
var myJump = GetJumpById(id);
|
||||
|
||||
Reference in New Issue
Block a user