Selector/Selector.Cache/Consumer/Factory/CacheWriterFactory.cs

38 lines
955 B
C#
Raw Normal View History

2021-10-28 23:05:07 +01:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using StackExchange.Redis;
namespace Selector.Cache
{
public interface ICacheWriterFactory {
public Task<IConsumer> Get(IPlayerWatcher watcher = null);
}
public class CacheWriterFactory: ICacheWriterFactory {
private readonly ILoggerFactory LoggerFactory;
private readonly IDatabaseAsync Cache;
public CacheWriterFactory(
IDatabaseAsync cache,
ILoggerFactory loggerFactory
) {
Cache = cache;
LoggerFactory = loggerFactory;
}
2022-02-25 18:32:43 +00:00
public Task<IConsumer> Get(IPlayerWatcher watcher = null)
2021-10-28 23:05:07 +01:00
{
2022-02-25 18:32:43 +00:00
return Task.FromResult<IConsumer>(new CacheWriter(
2021-10-28 23:05:07 +01:00
watcher,
Cache,
LoggerFactory.CreateLogger<CacheWriter>()
2022-02-25 18:32:43 +00:00
));
2021-10-28 23:05:07 +01:00
}
}
}