ana sayfa > MVC > MVC Web Helpers Cache

MVC Web Helpers Cache

Çarşamba, 27 Tem 2016 yorum ekle yorumlara git
@{
    var cacheItemKey = "CachedTime";
    var cacheHit = true;
    var time = WebCache.Get(cacheItemKey);

    if (time == null) {
        cacheHit = false;
    }

    if (cacheHit == false) {
        time = @DateTime.Now;
        WebCache.Set(cacheItemKey, time, 1, false);
    }
}
<!DOCTYPE html>
<html>
<head>
    <title>WebCache Helper Sample</title>
</head>
<body>
    <div>
        @if (cacheHit) {
            @:Found the time data in the cache.
        } else {
            @:Did not find the time data in the cache.
        }
    </div>
    <div>
        This page was cached at @time.
    </div>
</body>
</html>

 

Categories: MVC Tags:
  1. şimdilik yorum yok.
  1. şimdilik geri bağlantı yok
yorum yapabilmek için giriş yapmalısınız