Example usage for org.apache.commons.cache CacheStat NUM_RETRIEVE_NOT_FOUND

List of usage examples for org.apache.commons.cache CacheStat NUM_RETRIEVE_NOT_FOUND

Introduction

In this page you can find the example usage for org.apache.commons.cache CacheStat NUM_RETRIEVE_NOT_FOUND.

Prototype

CacheStat NUM_RETRIEVE_NOT_FOUND

To view the source code for org.apache.commons.cache CacheStat NUM_RETRIEVE_NOT_FOUND.

Click Source Link

Usage

From source file:com.adito.core.CoreUtil.java

/**
 * Store to cache, checking for serializable.
 * /*from  w w  w  .  j a v a 2  s. c  o m*/
 * @param cache cache to store object in 
 * @param key cache key
 * @param object object to cache
 * @param ttl time-to-live in milliseconds
 * @param cost cost
 */
public static void storeToCache(Cache cache, String key, Serializable object, long ttl, long cost) {
    if (log.isDebugEnabled()) {
        log.debug("Caching under " + key + ", ttl=" + ttl + ", cost=" + cost);
    }

    // NOTE Temporary code to make sure policy objects are serializable, in development and testing
    if ("true".equals(SystemProperties.get("adito.useDevConfig"))
            | "true".equals(SystemProperties.get("adito.testing"))) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(object);
        } catch (Exception e) {
            String string = "********** Failed to cache policy database object. There is probably a non-serializable object somewhere in the object graph. PLEASE FIX ME ****************";
            System.err.println(string);
            e.printStackTrace();
            throw new RuntimeException(string);
        }
    }

    cache.store(key, object, new Long(ttl + System.currentTimeMillis()), cost);
    if (log.isDebugEnabled()) {
        log.debug("NUM_RETRIEVE_REQUESTED " + cache.getStat(CacheStat.NUM_RETRIEVE_REQUESTED));
        log.debug("NUM_RETRIEVE_FOUND " + cache.getStat(CacheStat.NUM_RETRIEVE_FOUND));
        log.debug("NUM_RETRIEVE_NOT_FOUND " + cache.getStat(CacheStat.NUM_RETRIEVE_NOT_FOUND));
        log.debug("NUM_STORE_REQUESTED " + cache.getStat(CacheStat.NUM_STORE_REQUESTED));
        log.debug("NUM_STORE_STORED " + cache.getStat(CacheStat.NUM_STORE_STORED));
        log.debug("NUM_STORE_NOT_STORED " + cache.getStat(CacheStat.NUM_STORE_NOT_STORED));
        log.debug("CUR_CAPACITY " + cache.getStat(CacheStat.CUR_CAPACITY));
    }
}

From source file:com.sslexplorer.core.CoreUtil.java

/**
 * Store to cache, checking for serializable.
 * /*from  w  w w  . ja va 2s  .co m*/
 * @param cache cache to store object in 
 * @param key cache key
 * @param object object to cache
 * @param ttl time-to-live in milliseconds
 * @param cost cost
 */
public static void storeToCache(Cache cache, String key, Serializable object, long ttl, long cost) {
    if (log.isDebugEnabled()) {
        log.debug("Caching under " + key + ", ttl=" + ttl + ", cost=" + cost);
    }

    // NOTE Temporary code to make sure policy objects are serializable, in development and testing
    if ("true".equals(SystemProperties.get("sslexplorer.useDevConfig"))
            | "true".equals(SystemProperties.get("sslexplorer.testing"))) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(object);
        } catch (Exception e) {
            String string = "********** Failed to cache policy database object. There is probably a non-serializable object somewhere in the object graph. PLEASE FIX ME ****************";
            System.err.println(string);
            e.printStackTrace();
            throw new RuntimeException(string);
        }
    }

    cache.store(key, object, new Long(ttl + System.currentTimeMillis()), cost);
    if (log.isDebugEnabled()) {
        log.debug("NUM_RETRIEVE_REQUESTED " + cache.getStat(CacheStat.NUM_RETRIEVE_REQUESTED));
        log.debug("NUM_RETRIEVE_FOUND " + cache.getStat(CacheStat.NUM_RETRIEVE_FOUND));
        log.debug("NUM_RETRIEVE_NOT_FOUND " + cache.getStat(CacheStat.NUM_RETRIEVE_NOT_FOUND));
        log.debug("NUM_STORE_REQUESTED " + cache.getStat(CacheStat.NUM_STORE_REQUESTED));
        log.debug("NUM_STORE_STORED " + cache.getStat(CacheStat.NUM_STORE_STORED));
        log.debug("NUM_STORE_NOT_STORED " + cache.getStat(CacheStat.NUM_STORE_NOT_STORED));
        log.debug("CUR_CAPACITY " + cache.getStat(CacheStat.CUR_CAPACITY));
    }
}

From source file:com.adito.jdbc.JDBCPolicyDatabase.java

void storeToCache(String key, Serializable object) {
    if (log.isDebugEnabled()) {
        log.debug("Caching under " + key + ", ttl=" + CACHE_TTL + ", cost=" + CACHE_COST);
    }/* w ww  .j  a va 2s  .  com*/

    // NOTE Temporary code to make sure policy objects are serializable, in development and testing
    if ("true".equals(SystemProperties.get("adito.useDevConfig"))
            | "true".equals(SystemProperties.get("adito.testing"))) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(object);
        } catch (Exception e) {
            String string = "********** Failed to cache policy database object. There is probably a non-serializable object somewhere in the object graph. PLEASE FIX ME ****************";
            System.err.println(string);
            e.printStackTrace();
            throw new RuntimeException(string);
        }
    }

    policyCache.store(key, object, new Long(CACHE_TTL.longValue() + System.currentTimeMillis()), CACHE_COST);
    if (log.isDebugEnabled()) {
        log.debug("NUM_RETRIEVE_REQUESTED " + policyCache.getStat(CacheStat.NUM_RETRIEVE_REQUESTED));
        log.debug("NUM_RETRIEVE_FOUND " + policyCache.getStat(CacheStat.NUM_RETRIEVE_FOUND));
        log.debug("NUM_RETRIEVE_NOT_FOUND " + policyCache.getStat(CacheStat.NUM_RETRIEVE_NOT_FOUND));
        log.debug("NUM_STORE_REQUESTED " + policyCache.getStat(CacheStat.NUM_STORE_REQUESTED));
        log.debug("NUM_STORE_STORED " + policyCache.getStat(CacheStat.NUM_STORE_STORED));
        log.debug("NUM_STORE_NOT_STORED " + policyCache.getStat(CacheStat.NUM_STORE_NOT_STORED));
        log.debug("CUR_CAPACITY " + policyCache.getStat(CacheStat.CUR_CAPACITY));
    }
}

From source file:com.sslexplorer.jdbc.JDBCPolicyDatabase.java

void storeToCache(String key, Serializable object) {
    if (log.isDebugEnabled()) {
        log.debug("Caching under " + key + ", ttl=" + CACHE_TTL + ", cost=" + CACHE_COST);
    }//  w  ww  .jav a 2s  . c o  m

    // NOTE Temporary code to make sure policy objects are serializable, in development and testing
    if ("true".equals(SystemProperties.get("sslexplorer.useDevConfig"))
            | "true".equals(SystemProperties.get("sslexplorer.testing"))) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(object);
        } catch (Exception e) {
            String string = "********** Failed to cache policy database object. There is probably a non-serializable object somewhere in the object graph. PLEASE FIX ME ****************";
            System.err.println(string);
            e.printStackTrace();
            throw new RuntimeException(string);
        }
    }

    policyCache.store(key, object, new Long(CACHE_TTL.longValue() + System.currentTimeMillis()), CACHE_COST);
    if (log.isDebugEnabled()) {
        log.debug("NUM_RETRIEVE_REQUESTED " + policyCache.getStat(CacheStat.NUM_RETRIEVE_REQUESTED));
        log.debug("NUM_RETRIEVE_FOUND " + policyCache.getStat(CacheStat.NUM_RETRIEVE_FOUND));
        log.debug("NUM_RETRIEVE_NOT_FOUND " + policyCache.getStat(CacheStat.NUM_RETRIEVE_NOT_FOUND));
        log.debug("NUM_STORE_REQUESTED " + policyCache.getStat(CacheStat.NUM_STORE_REQUESTED));
        log.debug("NUM_STORE_STORED " + policyCache.getStat(CacheStat.NUM_STORE_STORED));
        log.debug("NUM_STORE_NOT_STORED " + policyCache.getStat(CacheStat.NUM_STORE_NOT_STORED));
        log.debug("CUR_CAPACITY " + policyCache.getStat(CacheStat.CUR_CAPACITY));
    }
}