Skip to content

Commit

Permalink
Remove database cache client (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
truongtphat authored Sep 12, 2024
1 parent 221b5ba commit 12b9782
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/mix.heart/Factories/CacheEngineFactory.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Configuration;
using Mix.Heart.Entities.Cache;
using Mix.Heart.Enums;
using Mix.Heart.Interfaces;
using Mix.Heart.Models;
using Mix.Heart.Services;
using Mix.Heart.UnitOfWork;
using System;

namespace Mix.Heart.Factories
{
public class CacheEngineFactory
{
public static IDitributedCacheClient? CreateCacheClient(
public static IDitributedCacheClient CreateCacheClient(
MixHeartConfigurationModel mixHeartConfiguration,
UnitOfWorkInfo<MixCacheDbContext> uow = null,
IConfiguration configuration = null,
IDistributedCache cache = null)
{
Expand Down
1 change: 0 additions & 1 deletion src/mix.heart/Services/ConfigurationServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Diagnostics.Contracts;

namespace Mix.Heart.Services
{
Expand Down
2 changes: 0 additions & 2 deletions src/mix.heart/Services/MixCacheService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Mix.Heart.Model;
using Mix.Heart.Models;
using Mix.Shared.Services;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -13,7 +12,6 @@ public class MixCacheService
private readonly MixDitributedCache _cache;
private readonly MixHeartConfigurationModel _configs;
public bool IsCacheEnabled { get => _configs.IsCache; }
protected JsonSerializer serializer;

public MixCacheService(MixDitributedCache ditributedCache)
{
Expand Down
1 change: 1 addition & 0 deletions src/mix.heart/Services/MixDatabaseCacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Mix.Heart.Services
{
[Obsolete("This feature will be removed.", true)]
public class MixDatabaseCacheClient : IDitributedCacheClient
{
private readonly JsonSerializer serializer;
Expand Down
6 changes: 2 additions & 4 deletions src/mix.heart/Services/MixDitributedCache.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Configuration;
using Mix.Heart.Entities.Cache;
using Mix.Heart.Factories;
using Mix.Heart.Interfaces;
using Mix.Heart.Models;
using Mix.Heart.UnitOfWork;
using Mix.Shared.Services;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -13,12 +11,12 @@ namespace Mix.Heart.Services
{
public class MixDitributedCache
{
private readonly IDitributedCacheClient? _cacheClient;
private readonly IDitributedCacheClient _cacheClient;
private readonly MixHeartConfigurationModel _configs;
public MixDitributedCache(IConfiguration configuration, IDistributedCache cache)
{
_configs = MixHeartConfigService.Instance.AppSettings;
_cacheClient = CacheEngineFactory.CreateCacheClient(_configs, default, configuration, cache);
_cacheClient = CacheEngineFactory.CreateCacheClient(_configs, configuration, cache);
}

public async Task<T> GetFromCache<T>(string key, CancellationToken cancellationToken = default) where T : class
Expand Down
1 change: 0 additions & 1 deletion src/mix.heart/ViewModel/ViewModelBase.Uow.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Mix.Heart.Enums;
using Mix.Heart.Exceptions;
using Mix.Heart.Services;
using Mix.Heart.UnitOfWork;
using System;
using System.Threading;
Expand Down

0 comments on commit 12b9782

Please sign in to comment.