CachingOfBizPropertySet(final OfBizPropertyEntryStore entryStore, final String entityName, final Long entityId) { this.entryStoreRef = Suppliers.memoize(entryStore); this.entity = new Entity(entityName, entityId); }
public static SortedMap<CacheStatisticsKey, Supplier<Long>> toStatistics(final StatisticsGateway stats) { // Note: While most of these statistics we can reasonably expect to be cheap and just memoize, the // heap size in bytes is very likely to be expensive. To make it possible to opt out of retrieving // it, we hide it behind a Supplier, here. final Supplier<Long> heapSize = new Supplier<Long>() { @Override public Long get() { return stats.getLocalHeapSizeInBytes(); } }; return ImmutableSortedMap.<CacheStatisticsKey,Supplier<Long>>orderedBy(CacheStatisticsKey.SORT_BY_LABEL) .put(SIZE, memoize(stats.getSize())) .put(HEAP_SIZE, heapSize) .put(HIT_COUNT, memoize(stats.cacheHitCount())) .put(PUT_COUNT, memoize(stats.cachePutCount())) .put(REMOVE_COUNT, memoize(stats.cacheRemoveCount())) .put(MISS_COUNT, memoize(stats.cacheMissCount())) .put(EVICTION_COUNT, memoize(stats.cacheEvictedCount())) .build(); } }