44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using FileService.Application.Ports;
|
|
using FileService.Application.StorageContracts;
|
|
using IM.Commons;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FileService.Infrastructure.Storage
|
|
{
|
|
public class StorageCacheService:IStorageRedisCache
|
|
{
|
|
private readonly IRedisService redis;
|
|
|
|
public StorageCacheService(IRedisService redis)
|
|
{
|
|
this.redis = redis;
|
|
}
|
|
public async Task SetAsync(UploadRuntimeCache upload)
|
|
{
|
|
string key = RedisHelper.GetUploadInfoKey(upload.UploadSessionId);
|
|
await redis.SetAsync<UploadRuntimeCache>(key, upload);
|
|
}
|
|
|
|
public async Task DeleteAsync(string sessionId)
|
|
{
|
|
string key = RedisHelper.GetUploadInfoKey(sessionId);
|
|
await redis.RemoveAsync(key);
|
|
}
|
|
|
|
public Task DeleteByTaskIdAsync(string taskId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public async Task<UploadRuntimeCache?> GetAsync(string sessionId)
|
|
{
|
|
var key = RedisHelper.GetUploadInfoKey(sessionId);
|
|
return await redis.GetAsync<UploadRuntimeCache>(key);
|
|
}
|
|
}
|
|
}
|