Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>Just save every queryresult to the database (with cache key: your query, value: your list of business objects)</li> <li>Use distributed cache like memcached next to ASP.Net cache</li> <li>Use a sophisticated cachemanager like <a href="https://github.com/enyim/memcached-providers" rel="noreferrer">https://github.com/enyim/memcached-providers</a>; that can have cache-groups. Some data has to be stored for a long time, some short time. Some data has to be stored in ASP.Net cache, etc.</li> <li>Do calls that has to be stored in the cache using a wrapper function like <code>public T GetFromCache&lt;T&gt;(string key, Func&lt;T&gt; ifKeyNotFoundDelegate)</code> to ensure that cache is always used the same. [1]</li> <li>Think of when to use ASP.Net cache, and when to use distributed cache. Data that is read every request should be stored in ASP.Net, large data like search results; with a lot of different keys and data etc. should be in memcached.</li> <li>Add versioning. Prefix all keys with a versionnumber, so you won't get in trouble when updating your web application, and some objectcontracts change.</li> </ul> <p>Ah well, that covers most of what we do in our website (20GB memcached cluster spread over 20 servers).</p> <p>[1] By making such a function the only interface to store stuff in cache, you can achieve the following. Let's say I want to use something from the cache, like the result from a function. Normally you would do something like</p> <pre><code>CacheManager cm = new CacheManager(CacheGroups.Totals); object obj = cm.GetFromCache("function1result"); if(obj == null) { obj = (object)DAO.Foo(); cm.StoreInCache("function1result", obj); } return (List&lt;MyEntity&gt;)obj; </code></pre> <p>By using a different interface you can ensure that users won't make a mistake here.</p> <p>Like</p> <pre><code>public T GetFromCache&lt;T&gt;(string key, Func&lt;T&gt; ifnotfound) { T obj = this.GetFromCache(key) as T; if(obj == default(T)) { obj = ifnotfound.Invoke(); this.StoreInCache(key, obj); } return obj; } </code></pre> <p>This ensures that</p> <ol> <li>We always work with the correct type</li> <li>That your user always work with cache the same way</li> </ol> <p>Ergo: less probable that they make a mistake. Furthermore: you get nicer, more clear, code, like:</p> <pre><code>List&lt;MyEntity&gt; list = new CacheManager(CacheGroups.Total).GetFromCache&lt;List&lt;MyEntity&gt;&gt;("function1result", ()=&gt;DAO.Foo()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload