Add a cache system on the referential info

+ Add an identity service
This commit is contained in:
Sébastien André
2021-04-17 22:17:45 +02:00
parent 0bb9ed2a30
commit 143127cd01
30 changed files with 955 additions and 570 deletions

View File

@@ -1,23 +1,31 @@
using System;
using System.Collections.Generic;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.DomainBusiness
{
public class JumpTypeService : IJumpTypeService
{
public JumpTypeService(IJumpTypeRepository jumpTypeRepository)
#region Public Constructors
public JumpTypeService(IJumpTypeRepository jumpTypeRepository,
ICacheService cacheService)
{
_jumpTypeRepository = jumpTypeRepository;
_cacheService = cacheService;
}
#endregion Public Constructors
#region Public Methods
public void AddNewJumpType(JumpType newJumpType)
{
_jumpTypeRepository.Add(newJumpType);
_cacheService.Delete(CacheType.JumpType);
}
public void DeleteJumpTypeById(int id)
@@ -27,12 +35,18 @@ namespace skydiveLogs_api.DomainBusiness
public IEnumerable<JumpType> GetAllJumpTypes()
{
return _jumpTypeRepository.GetAll();
if (!_cacheService.Contains(CacheType.JumpType))
_cacheService.Put(CacheType.JumpType,
_jumpTypeRepository.GetAll(),
5 * 60 * 1000);
return _cacheService.Get<IEnumerable<JumpType>>(CacheType.JumpType);
}
public JumpType GetJumpTypeById(int id)
{
return _jumpTypeRepository.GetById(id);
var allJumpTypes = GetAllJumpTypes();
return allJumpTypes.Single(g => g.Id == id);
}
public void UpdateJumpType(int id, JumpType value)
@@ -40,6 +54,13 @@ namespace skydiveLogs_api.DomainBusiness
throw new NotImplementedException();
}
#endregion Public Methods
#region Private Fields
private readonly ICacheService _cacheService;
private readonly IJumpTypeRepository _jumpTypeRepository;
#endregion Private Fields
}
}
}