# SqlAdapterCache Replacement Policy

**URL:** <https://community.origam.com/t/sqladaptercache-replacement-policy/947>\
**Category:** dev\
**Tags:** server, product-backlog\
**Created:** [June 7, 2021, 7:37am UTC](https://community.origam.com/t/sqladaptercache-replacement-policy/947 "2021-06-07T07:37:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![washi](https://community.origam.com/user_avatar/community.origam.com/washi/32/217_2.png) [@washi](https://community.origam.com/u/washi)\
**Post date:** [June 7, 2021, 7:37am UTC](https://community.origam.com/t/sqladaptercache-replacement-policy/947/1 "2021-06-07T07:37:05Z")

</div>

During memory dump analysis of Origam server it was found out, that SqlAdapterCache doesn’t have any replacement policy implemented, thus growing indefinitely during the server’s lifetime.

> **[Cache replacement policies](https://en.wikipedia.org/wiki/Cache_replacement_policies)**
>
> In computing, cache replacement policies (also known as cache replacement algorithms or cache algorithms) are optimizing instructions or algorithms which a computer program or hardware-maintained structure can utilize to manage a cache of information. Caching improves performance by keeping recent or often-used data items in memory locations which are faster, or computationally cheaper to access, than normal memory stores. When the cache is full, the algorithm must choose which items to discard ...

We should implement one. I suggest TLRU.

---

<div class="post-metadata">

**Author:** ![tvavrda](https://community.origam.com/user_avatar/community.origam.com/tvavrda/32/24_2.png) [@tvavrda](https://community.origam.com/u/tvavrda)\
**Post date:** [June 7, 2021, 8:11am UTC](https://community.origam.com/t/sqladaptercache-replacement-policy/947/2 "2021-06-07T08:11:15Z")

</div>

Agree if it seems to be a real issue (in case od adapter caching that would mean many users would only login once, leaving the cache growing).

> **[Cache in-memory in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-5.0)**
>
> Learn how to cache data in memory in ASP.NET Core.

So sliding expiration option would be appropriate here.
