Exemplo n.º 1
0
def stats_page(request):
    calls = keyedcache.CACHE_CALLS
    hits = keyedcache.CACHE_HITS

    if (calls and hits):
        rate =  float(keyedcache.CACHE_HITS)/keyedcache.CACHE_CALLS*100
    else:
        rate = 0

    try:
        running = keyedcache.cache_require()

    except keyedcache.CacheNotRespondingError:
        running = False

    ctx = RequestContext(request, {
        'cache_count' : len(keyedcache.CACHED_KEYS),
        'cache_running' : running,
        'cache_time' : keyedcache.CACHE_TIMEOUT,
        'cache_backend' : keyedcache.CACHE_BACKEND,
        'cache_calls' : keyedcache.CACHE_CALLS,
        'cache_hits' : keyedcache.CACHE_HITS,
        'hit_rate' : "%02.1f" % rate
    })

    return render_to_response('keyedcache/stats.html', context_instance=ctx)
Exemplo n.º 2
0
def stats_page(request):
    calls = keyedcache.CACHE_CALLS
    hits = keyedcache.CACHE_HITS

    if (calls and hits):
        rate =  float(keyedcache.CACHE_HITS)/keyedcache.CACHE_CALLS*100
    else:
        rate = 0

    try:
        running = keyedcache.cache_require()

    except keyedcache.CacheNotRespondingError:
        running = False

    ctx = RequestContext(request, {
        'cache_count' : len(keyedcache.CACHED_KEYS),
        'cache_running' : running,
        'cache_time' : keyedcache.CACHE_TIMEOUT,
        'cache_backend' : keyedcache.cache.__module__,
        'cache_calls' : keyedcache.CACHE_CALLS,
        'cache_hits' : keyedcache.CACHE_HITS,
        'hit_rate' : "%02.1f" % rate
    })

    return render_to_response('keyedcache/stats.html', context_instance=ctx)
Exemplo n.º 3
0
def stats_page(request):
    calls = keyedcache.CACHE_CALLS
    hits = keyedcache.CACHE_HITS

    if (calls and hits):
        rate = float(keyedcache.CACHE_HITS) / keyedcache.CACHE_CALLS * 100
    else:
        rate = 0

    try:
        running = keyedcache.cache_require()

    except keyedcache.CacheNotRespondingError:
        running = False

    ctx = {
        'cache_count': len(keyedcache.CACHED_KEYS),
        'cache_running': running,
        'cache_time': keyedcache.CACHE_TIMEOUT,
        'cache_backend': keyedcache.cache.__module__,
        'cache_calls': keyedcache.CACHE_CALLS,
        'cache_hits': keyedcache.CACHE_HITS,
        'hit_rate': "%02.1f" % rate
    }

    return render(request, 'keyedcache/stats.html', ctx)