Picasso p = new Picasso.Builder(context) .memoryCache(new LruCache(24000)) .build();
if (isThresholdReached()) { if (!isUnbounded) overflow = trimLru(lc.lastAccessed); else updateThreshold = true;
/** * Returns the current lenght of the LRU list */ public Integer getLruListLength() { return (Integer) lruCache.getStatByName( Constants.STAT_LRUCACHE_LIST_LENGTH); }
/** * item value has been refreshed * @param item <code>CacheItem</code> that was refreshed * @param oldSize size of the previous value that was refreshed * Cache bucket is already synchronized by the caller */ protected void itemRefreshed(CacheItem item, int oldSize) { itemAccessed(item); }
/** * initialize the cache * @param maxEntries maximum number of entries expected in the cache * @param loadFactor the load factor * @param timeout to be used to trim the expired entries * @param props opaque list of properties for a given cache implementation * @throws a generic Exception if the initialization failed */ public void init(int maxEntries, long timeout, float loadFactor, Properties props) { // if the max entries is <= 0 then set the default max entries if (maxEntries <= 0) { maxEntries = defaultMaxEntries; // mark this cache unbounded isUnbounded = true; } setTimeout(timeout); super.init(maxEntries, loadFactor, props); }
trimItem((LruCacheItem) list.get(index));
protected void createReadyStore(int cacheSize, int numberOfVictimsToSelect, float loadFactor, long idleTimeout) throws Exception { idleTimeout = (idleTimeout <= 0) ? -1 : idleTimeout; if (cacheSize <= 0 && idleTimeout <= 0) { readyStore = new BaseCache(); cacheSize = DEFAULT_CACHE_SIZE; readyStore.init(cacheSize, loadFactor, null); } else { cacheSize = (cacheSize <= 0) ? DEFAULT_CACHE_SIZE : cacheSize; LruCache lru = new LruCache(DEFAULT_CACHE_SIZE); if (numberOfVictimsToSelect >= 0) { loadFactor = (float) (1.0 - (1.0 * numberOfVictimsToSelect/cacheSize)); } lru.init(cacheSize, idleTimeout, loadFactor, null); readyStore = lru; readyStore.addCacheListener(this); } if (idleTimeout > 0) { idleBeansPassivator = setupIdleBeansPassivator(readyStore); } }
@Override protected CacheItem itemAdded(CacheItem item) { boolean wasUnbounded = isUnbounded; CacheItem overflow = null; // force not to check isUnbounded = false; try { overflow = super.itemAdded(item); } finally { //restore isUnbounded = wasUnbounded; } return overflow; }
if (isThresholdReached()) { if (!isUnbounded) overflow = trimLru(lc.lastAccessed); else updateThreshold = true;
/** * Returns the number of entries that have been trimmed */ public Integer getTrimCount() { return (Integer) lruCache.getStatByName( Constants.STAT_LRUCACHE_TRIM_COUNT); } }
/** * item value has been refreshed * @param item <code>CacheItem</code> that was refreshed * @param oldSize size of the previous value that was refreshed * Cache bucket is already synchronized by the caller */ protected void itemRefreshed(CacheItem item, int oldSize) { itemAccessed(item); }
/** * initialize the cache * @param maxEntries maximum number of entries expected in the cache * @param loadFactor the load factor * @param timeout to be used to trim the expired entries * @param props opaque list of properties for a given cache implementation * @throws a generic Exception if the initialization failed */ public void init(int maxEntries, long timeout, float loadFactor, Properties props) { // if the max entries is <= 0 then set the default max entries if (maxEntries <= 0) { maxEntries = defaultMaxEntries; // mark this cache unbounded isUnbounded = true; } setTimeout(timeout); super.init(maxEntries, loadFactor, props); }
trimItem((LruCacheItem) list.get(index));
if (isThresholdReached()) { if (!isUnbounded) overflow = trimLru(lc.lastAccessed); else updateThreshold = true;
/** * Returns the current lenght of the LRU list */ public Integer getLruListLength() { return (Integer) lruCache.getStatByName( Constants.STAT_LRUCACHE_LIST_LENGTH); }
.memoryCache(new LruCache(100000000)) // Maybe something fishy here?
/** * item value has been refreshed * @param item <code>CacheItem</code> that was refreshed * @param oldSize size of the previous value that was refreshed * Cache bucket is already synchronized by the caller */ protected void itemRefreshed(CacheItem item, int oldSize) { itemAccessed(item); }
/** * initialize the cache * @param maxEntries maximum number of entries expected in the cache * @param loadFactor the load factor * @param timeout to be used to trim the expired entries * @param props opaque list of properties for a given cache implementation * @throws a generic Exception if the initialization failed */ public void init(int maxEntries, long timeout, float loadFactor, Properties props) { // if the max entries is <= 0 then set the default max entries if (maxEntries <= 0) { maxEntries = defaultMaxEntries; // mark this cache unbounded isUnbounded = true; } setTimeout(timeout); super.init(maxEntries, loadFactor, props); }
trimItem((LruCacheItem) list.get(index));
if (isThresholdReached()) { if (!isUnbounded) overflow = trimLru(lc.lastAccessed); else updateThreshold = true;