Fixed an issue with the caching

pull/1676/head
tidusjar 7 years ago
parent 22a23d652b
commit ef858a9fce

@ -72,6 +72,7 @@ namespace Ombi.Core.Engine
RequestedDate = DateTime.UtcNow, RequestedDate = DateTime.UtcNow,
Approved = false, Approved = false,
RequestedUserId = userDetails.Id, RequestedUserId = userDetails.Id,
Background = movieInfo.BackdropPath
}; };
var ruleResults = (await RunRequestRules(requestModel)).ToList(); var ruleResults = (await RunRequestRules(requestModel)).ToList();

@ -11,6 +11,7 @@ namespace Ombi.Store.Entities.Requests
public string PosterPath { get; set; } public string PosterPath { get; set; }
public DateTime ReleaseDate { get; set; } public DateTime ReleaseDate { get; set; }
public string Status { get; set; } public string Status { get; set; }
public string Background { get; set; }
[NotMapped] [NotMapped]

@ -22,7 +22,7 @@ namespace Ombi.Store.Repository
public GlobalSettings Insert(GlobalSettings entity) public GlobalSettings Insert(GlobalSettings entity)
{ {
_cache.Remove(entity.SettingsName); _cache.Remove(GetName(entity.SettingsName));
var settings = Db.Settings.Add(entity); var settings = Db.Settings.Add(entity);
Db.SaveChanges(); Db.SaveChanges();
return settings.Entity; return settings.Entity;
@ -30,7 +30,7 @@ namespace Ombi.Store.Repository
public async Task<GlobalSettings> InsertAsync(GlobalSettings entity) public async Task<GlobalSettings> InsertAsync(GlobalSettings entity)
{ {
_cache.Remove(entity.SettingsName); _cache.Remove(GetName(entity.SettingsName));
var settings = await Db.Settings.AddAsync(entity).ConfigureAwait(false); var settings = await Db.Settings.AddAsync(entity).ConfigureAwait(false);
await Db.SaveChangesAsync().ConfigureAwait(false); await Db.SaveChangesAsync().ConfigureAwait(false);
return settings.Entity; return settings.Entity;
@ -39,7 +39,7 @@ namespace Ombi.Store.Repository
public GlobalSettings Get(string pageName) public GlobalSettings Get(string pageName)
{ {
return _cache.GetOrCreate(pageName, entry => return _cache.GetOrCreate(GetName(pageName), entry =>
{ {
entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1); entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1);
var entity = Db.Settings.AsNoTracking().FirstOrDefault(x => x.SettingsName == pageName); var entity = Db.Settings.AsNoTracking().FirstOrDefault(x => x.SettingsName == pageName);
@ -49,7 +49,7 @@ namespace Ombi.Store.Repository
public async Task<GlobalSettings> GetAsync(string settingsName) public async Task<GlobalSettings> GetAsync(string settingsName)
{ {
return await _cache.GetOrCreateAsync(settingsName, async entry => return await _cache.GetOrCreateAsync(GetName(settingsName), async entry =>
{ {
entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1); entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1);
var obj = await Db.Settings.AsNoTracking().FirstOrDefaultAsync(x => x.SettingsName == settingsName); var obj = await Db.Settings.AsNoTracking().FirstOrDefaultAsync(x => x.SettingsName == settingsName);
@ -59,29 +59,34 @@ namespace Ombi.Store.Repository
public async Task DeleteAsync(GlobalSettings entity) public async Task DeleteAsync(GlobalSettings entity)
{ {
_cache.Remove(entity.SettingsName); _cache.Remove(GetName(entity.SettingsName));
Db.Settings.Remove(entity); Db.Settings.Remove(entity);
await Db.SaveChangesAsync(); await Db.SaveChangesAsync();
} }
public async Task UpdateAsync(GlobalSettings entity) public async Task UpdateAsync(GlobalSettings entity)
{ {
_cache.Remove(entity.SettingsName); _cache.Remove(GetName(entity.SettingsName));
Db.Update(entity); Db.Update(entity);
await Db.SaveChangesAsync(); await Db.SaveChangesAsync();
} }
public void Delete(GlobalSettings entity) public void Delete(GlobalSettings entity)
{ {
_cache.Remove(entity.SettingsName); _cache.Remove(GetName(entity.SettingsName));
Db.Settings.Remove(entity); Db.Settings.Remove(entity);
Db.SaveChanges(); Db.SaveChanges();
} }
public void Update(GlobalSettings entity) public void Update(GlobalSettings entity)
{ {
_cache.Remove(entity.SettingsName); _cache.Remove(GetName(entity.SettingsName));
Db.SaveChanges(); Db.SaveChanges();
} }
private string GetName(string entity)
{
return $"{entity}Json";
}
} }
} }
Loading…
Cancel
Save