[#23] Client: Refactoring to optimize memory usage
Signed-off-by: Pavel Gross <p.gross@yando.com>
This commit is contained in:
parent
1a02ac2ae7
commit
6562aa27a5
141 changed files with 1722 additions and 896 deletions
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
|
@ -13,16 +15,19 @@ public static class ContainerIdMapper
|
|||
.SetSlidingExpiration(TimeSpan.FromHours(1))
|
||||
.SetSize(1);
|
||||
|
||||
public static ContainerID ToMessage(this ContainerId model)
|
||||
public static ContainerID ToMessage(this FrostFsContainerId model)
|
||||
{
|
||||
if (!Cache.Containers.TryGetValue(model, out ContainerID? message))
|
||||
if (model.Value == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
|
||||
if (!Cache.Containers.TryGetValue(model.Value, out ContainerID? message))
|
||||
{
|
||||
message = new ContainerID
|
||||
{
|
||||
Value = ByteString.CopyFrom(Base58.Decode(model.Value))
|
||||
};
|
||||
|
||||
Cache.Containers.Set(model, message, _oneHourExpiration);
|
||||
Cache.Containers.Set(model.Value, message, _oneHourExpiration);
|
||||
}
|
||||
|
||||
return message!;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue