<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cache on MemoryLeak</title><link>https://blog.memoryleak.ovh/tags/cache/</link><description>Recent content in Cache on MemoryLeak</description><generator>Hugo</generator><language>fr</language><lastBuildDate>Fri, 11 Apr 2014 13:13:00 +0000</lastBuildDate><atom:link href="https://blog.memoryleak.ovh/tags/cache/index.xml" rel="self" type="application/rss+xml"/><item><title>Utiliser Couchbase comme serveur de cache</title><link>https://blog.memoryleak.ovh/posts/utiliser-couchbase-comme-serveur-de-cache/</link><pubDate>Fri, 11 Apr 2014 13:13:00 +0000</pubDate><guid>https://blog.memoryleak.ovh/posts/utiliser-couchbase-comme-serveur-de-cache/</guid><description>&lt;p&gt;Dernièrement, je vous présentais une façon simple d&amp;rsquo;utiliser le &lt;a href="http://mymemoryleaks.blogspot.fr/2014/04/poor-mans-cache.html" target="_blank"&gt;cache dans vos applications .NET&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cependant cette solution possède plusieurs inconvénients. En voici quelque uns :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Le cache est lié au processus système de votre application (executable / IIS etc&amp;hellip;). Si votre programme plante ou est fermé, vous perdez votre cache&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Si vos besoins en mémoire augmentent, cette solution n&amp;rsquo;est pas scalable&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rien n&amp;rsquo;est mis a disposition pour monitorer votre cache&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Vous n&amp;rsquo;avez pas d&amp;rsquo;interface de gestion du cache (augmentation de la mémoire allouée etc&amp;hellip;)&lt;/p&gt;</description></item><item><title>Poor man's cache</title><link>https://blog.memoryleak.ovh/posts/poor-man-s-cache/</link><pubDate>Fri, 04 Apr 2014 15:10:00 +0000</pubDate><guid>https://blog.memoryleak.ovh/posts/poor-man-s-cache/</guid><description>&lt;p&gt;Depuis la version 4 du framework .NET, la gestion d&amp;rsquo;un cache est profondement encrée dans l&amp;rsquo;adn de notre framework.&lt;/p&gt;
&lt;p&gt;Il devient alors extrêmement facile de stocker en mémoire à peu près n&amp;rsquo;importe quoi.&lt;/p&gt;
&lt;p&gt;Je vous livre dans ce court billet, une implémentation extrêmement simple que j&amp;rsquo;utilise souvent dans mes projets.&lt;/p&gt;
&lt;p&gt;Commençons par définir une interface, qui nous permettra [d&amp;rsquo;injecter](&lt;a href="http://blog.ploeh.dk/tags.html#Dependency" target="_blank"&gt;http://blog.ploeh.dk/tags.html#Dependency&lt;/a&gt; Injection-ref) notre cache manager un peu partout :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;public interface ICacheManager
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; T GetOrInsert(string key, Func callback) where T : class;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;et finalement voici une implémentation extra simple de notre cache manager&lt;/p&gt;</description></item></channel></rss>