/
veer
/
Zaya.Translator
Обзор
Документация
Войти
/
veer
/
Zaya.Translator
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
docs/api/Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.html
338 строк
18 KB
Vladimir Makarov
Extract TranslatorCache as a separate interface and Memory plugin.
01 авг 2026, 22:01
01 авг 2026, 22:01
d289f8b
Код
Авторство
О чём код?
<!DOCTYPE html> <!--[if IE]><![endif]--> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Class MemoryTranslationCache </title> <meta name="viewport" content="width=device-width"> <meta name="title" content="Class MemoryTranslationCache "> <meta name="description" content="In-memory exact translation cache with optional TTL eviction. Thread-safe only for single-threaded consumers (the translation loop is single-threaded)."> <link rel="shortcut icon" href="../favicon.ico"> <link rel="stylesheet" href="../styles/docfx.vendor.min.css"> <link rel="stylesheet" href="../styles/docfx.css"> <link rel="stylesheet" href="../styles/main.css"> <meta property="docfx:navrel" content="../toc.html"> <meta property="docfx:tocrel" content="toc.html"> </head> <body data-spy="scroll" data-target="#affix" data-offset="120"> <div id="wrapper"> <header> <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="../index.html"> <img id="logo" class="svg" src="../logo.svg" alt=""> </a> </div> <div class="collapse navbar-collapse" id="navbar"> <form class="navbar-form navbar-right" role="search" id="search"> <div class="form-group"> <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off"> </div> </form> </div> </div> </nav> <div class="subnav navbar navbar-default"> <div class="container hide-when-search" id="breadcrumb"> <ul class="breadcrumb"> <li></li> </ul> </div> </div> </header> <div role="main" class="container body-content hide-when-search"> <div class="sidenav hide-when-search"> <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a> <div class="sidetoggle collapse" id="sidetoggle"> <div id="sidetoc"></div> </div> </div> <div class="article row grid-right"> <div class="col-md-10"> <article class="content wrap" id="_content" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache"> <h1 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache" class="text-break">Class MemoryTranslationCache</h1> <div class="markdown level0 summary"><p>In-memory exact translation cache with optional TTL eviction. Thread-safe only for single-threaded consumers (the translation loop is single-threaded).</p> </div> <div class="markdown level0 conceptual"></div> <div class="inheritance"> <h5>Inheritance</h5> <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div> <div class="level1"><span class="xref">MemoryTranslationCache</span></div> </div> <div class="implements"> <h5>Implements</h5> <div><a class="xref" href="Zaya.TranslatorCache.Impl.Memory.Services.ITranslationCache.html">ITranslationCache</a></div> </div> <div class="inheritedMembers"> <h5>Inherited Members</h5> <div> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a> </div> <div> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a> </div> <div> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a> </div> <div> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a> </div> <div> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a> </div> <div> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a> </div> </div> <h6><strong>Namespace</strong>: <a class="xref" href="Zaya.html">Zaya</a>.<a class="xref" href="Zaya.TranslatorCache.html">TranslatorCache</a>.<a class="xref" href="Zaya.TranslatorCache.Impl.html">Impl</a>.<a class="xref" href="Zaya.TranslatorCache.Impl.Memory.html">Memory</a>.<a class="xref" href="Zaya.TranslatorCache.Impl.Memory.Services.html">Services</a></h6> <h6><strong>Assembly</strong>: Zaya.TranslatorCache.Impl.Memory.dll</h6> <h5 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_syntax">Syntax</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public sealed class MemoryTranslationCache : ITranslationCache</code></pre> </div> <h3 id="constructors">Constructors </h3> <span class="small pull-right mobile-hide"> <span class="divider">|</span> <a href="https://github.com/shtrasser-dev/Zaya.Translator/new/main/apiSpec/new?filename=Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache__ctor_System_Nullable_System_TimeSpan__.md&value=---%0Auid%3A%20Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.%23ctor(System.Nullable%7BSystem.TimeSpan%7D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Edit this page</a> </span> <span class="small pull-right mobile-hide"> <a href="https://github.com/shtrasser-dev/Zaya.Translator/blob/main/src/Zaya.TranslatorCache.Impl.Memory/Services/MemoryTranslationCache.cs/#L17">View Source</a> </span> <a id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache__ctor_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.#ctor*"></a> <h4 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache__ctor_System_Nullable_System_TimeSpan__" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.#ctor(System.Nullable{System.TimeSpan})">MemoryTranslationCache(TimeSpan?)</h4> <div class="markdown level1 summary"><p>Initializes a new instance with optional TTL.</p> </div> <div class="markdown level1 conceptual"></div> <h5 class="declaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public MemoryTranslationCache(TimeSpan? ttl = null)</code></pre> </div> <h5 class="parameters">Parameters</h5> <table class="table table-bordered table-condensed"> <thead> <tr> <th>Type</th> <th>Name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.timespan">TimeSpan</a>?</td> <td><span class="parametername">ttl</span></td> <td></td> </tr> </tbody> </table> <span class="small pull-right mobile-hide"> <span class="divider">|</span> <a href="https://github.com/shtrasser-dev/Zaya.Translator/new/main/apiSpec/new?filename=Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache__ctor_Zaya_TranslatorCache_Impl_Memory_Services_TranslationCacheOptions_.md&value=---%0Auid%3A%20Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.%23ctor(Zaya.TranslatorCache.Impl.Memory.Services.TranslationCacheOptions)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Edit this page</a> </span> <span class="small pull-right mobile-hide"> <a href="https://github.com/shtrasser-dev/Zaya.Translator/blob/main/src/Zaya.TranslatorCache.Impl.Memory/Services/MemoryTranslationCache.cs/#L25">View Source</a> </span> <a id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache__ctor_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.#ctor*"></a> <h4 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache__ctor_Zaya_TranslatorCache_Impl_Memory_Services_TranslationCacheOptions_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.#ctor(Zaya.TranslatorCache.Impl.Memory.Services.TranslationCacheOptions)">MemoryTranslationCache(TranslationCacheOptions)</h4> <div class="markdown level1 summary"><p>Initializes a new instance with the specified options.</p> </div> <div class="markdown level1 conceptual"></div> <h5 class="declaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public MemoryTranslationCache(TranslationCacheOptions options)</code></pre> </div> <h5 class="parameters">Parameters</h5> <table class="table table-bordered table-condensed"> <thead> <tr> <th>Type</th> <th>Name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><a class="xref" href="Zaya.TranslatorCache.Impl.Memory.Services.TranslationCacheOptions.html">TranslationCacheOptions</a></td> <td><span class="parametername">options</span></td> <td></td> </tr> </tbody> </table> <h3 id="methods">Methods </h3> <span class="small pull-right mobile-hide"> <span class="divider">|</span> <a href="https://github.com/shtrasser-dev/Zaya.Translator/new/main/apiSpec/new?filename=Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_Clear.md&value=---%0Auid%3A%20Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.Clear%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Edit this page</a> </span> <span class="small pull-right mobile-hide"> <a href="https://github.com/shtrasser-dev/Zaya.Translator/blob/main/src/Zaya.TranslatorCache.Impl.Memory/Services/MemoryTranslationCache.cs/#L63">View Source</a> </span> <a id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_Clear_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.Clear*"></a> <h4 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_Clear" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.Clear">Clear()</h4> <div class="markdown level1 summary"><p>Removes all entries from the cache.</p> </div> <div class="markdown level1 conceptual"></div> <h5 class="declaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public void Clear()</code></pre> </div> <span class="small pull-right mobile-hide"> <span class="divider">|</span> <a href="https://github.com/shtrasser-dev/Zaya.Translator/new/main/apiSpec/new?filename=Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_Set_System_String_System_String_.md&value=---%0Auid%3A%20Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.Set(System.String%2CSystem.String)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Edit this page</a> </span> <span class="small pull-right mobile-hide"> <a href="https://github.com/shtrasser-dev/Zaya.Translator/blob/main/src/Zaya.TranslatorCache.Impl.Memory/Services/MemoryTranslationCache.cs/#L54">View Source</a> </span> <a id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_Set_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.Set*"></a> <h4 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_Set_System_String_System_String_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.Set(System.String,System.String)">Set(string, string)</h4> <div class="markdown level1 summary"><p>Stores a translation result for the specified source text.</p> </div> <div class="markdown level1 conceptual"></div> <h5 class="declaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public void Set(string sourceText, string translation)</code></pre> </div> <h5 class="parameters">Parameters</h5> <table class="table table-bordered table-condensed"> <thead> <tr> <th>Type</th> <th>Name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td> <td><span class="parametername">sourceText</span></td> <td></td> </tr> <tr> <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td> <td><span class="parametername">translation</span></td> <td></td> </tr> </tbody> </table> <span class="small pull-right mobile-hide"> <span class="divider">|</span> <a href="https://github.com/shtrasser-dev/Zaya.Translator/new/main/apiSpec/new?filename=Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_TryGet_System_String_System_String__.md&value=---%0Auid%3A%20Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.TryGet(System.String%2CSystem.String%40)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Edit this page</a> </span> <span class="small pull-right mobile-hide"> <a href="https://github.com/shtrasser-dev/Zaya.Translator/blob/main/src/Zaya.TranslatorCache.Impl.Memory/Services/MemoryTranslationCache.cs/#L32">View Source</a> </span> <a id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_TryGet_" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.TryGet*"></a> <h4 id="Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache_TryGet_System_String_System_String__" data-uid="Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache.TryGet(System.String,System.String@)">TryGet(string, out string?)</h4> <div class="markdown level1 summary"><p>Attempts to retrieve a cached translation for the specified source text.</p> </div> <div class="markdown level1 conceptual"></div> <h5 class="declaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public bool TryGet(string sourceText, out string? translation)</code></pre> </div> <h5 class="parameters">Parameters</h5> <table class="table table-bordered table-condensed"> <thead> <tr> <th>Type</th> <th>Name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td> <td><span class="parametername">sourceText</span></td> <td></td> </tr> <tr> <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td> <td><span class="parametername">translation</span></td> <td></td> </tr> </tbody> </table> <h5 class="returns">Returns</h5> <table class="table table-bordered table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td> <td></td> </tr> </tbody> </table> <h3 id="implements">Implements</h3> <div> <a class="xref" href="Zaya.TranslatorCache.Impl.Memory.Services.ITranslationCache.html">ITranslationCache</a> </div> </article> </div> <div class="hidden-sm col-md-2" role="complementary"> <div class="sideaffix"> <div class="contribution"> <ul class="nav"> <li> <a href="https://github.com/shtrasser-dev/Zaya.Translator/new/main/apiSpec/new?filename=Zaya_TranslatorCache_Impl_Memory_Services_MemoryTranslationCache.md&value=---%0Auid%3A%20Zaya.TranslatorCache.Impl.Memory.Services.MemoryTranslationCache%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Edit this page</a> </li> <li> <a href="https://github.com/shtrasser-dev/Zaya.Translator/blob/main/src/Zaya.TranslatorCache.Impl.Memory/Services/MemoryTranslationCache.cs/#L9" class="contribution-link">View Source</a> </li> </ul> </div> <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix"> <h5>In this article</h5> <div></div> </nav> </div> </div> </div> </div> <footer> <div class="grad-bottom"></div> <div class="footer"> <div class="container"> <span class="pull-right"> <a href="#top">Back to top</a> </span> <span>Generated by <strong>DocFX</strong></span> </div> </div> </footer> </div> <script type="text/javascript" src="../styles/docfx.vendor.min.js"></script> <script type="text/javascript" src="../styles/docfx.js"></script> <script type="text/javascript" src="../styles/main.js"></script> </body> </html>