K
- cache key typeV
- cache value typepublic class OHCacheBuilder<K,V> extends Object
Field | Meaning | Default |
---|---|---|
keySerializer |
Serializer implementation used for keys | Must be configured |
valueSerializer |
Serializer implementation used for values | Must be configured |
executorService |
Executor service required for get operations using a cache loader. E.g. OHCache.getWithLoaderAsync(Object, CacheLoader) |
(Not configured by default meaning get operations with cache loader not supported by default) |
segmentCount |
Number of segments | 2 * number of CPUs (java.lang.Runtime.availableProcessors() ) |
hashTableSize |
Initial size of each segment's hash table | 8192 |
loadFactor |
Hash table load factor. I.e. determines when rehashing occurs. | .75f |
capacity |
Capacity of the cache in bytes | 16 MB * number of CPUs (java.lang.Runtime.availableProcessors() ), minimum 64 MB |
maxEntrySize |
Maximum size of a hash entry (including header, serialized key + serialized value) | (not set, defaults to capacity) |
bucketLength |
(For tables implementation only) Number of entries per bucket. | 8 |
throwOOME |
Throw OutOfMemoryError if off-heap allocation fails |
false |
hashAlgorighm |
Hash algorithm to use internally. Valid options are: XX for xx-hash, MURMUR3 or CRC32
Note: this setting does may only help to improve throughput in rare situations - i.e. if the key is
very long and you've proven that it really improves performace |
MURMUR3 |
You may also use system properties prefixed with org.caffinitas.org.
to other defaults.
E.g. the system property org.caffinitas.org.segmentCount
configures the default of the number of segments.
Modifier and Type | Field and Description |
---|---|
static String |
SYSTEM_PROPERTY_PREFIX |
public static final String SYSTEM_PROPERTY_PREFIX
public static <K,V> OHCacheBuilder<K,V> newBuilder()
public OHCacheBuilder<K,V> type(Class<? extends OHCache> type)
public int getHashTableSize()
public OHCacheBuilder<K,V> hashTableSize(int hashTableSize)
public int getBucketLength()
public OHCacheBuilder<K,V> bucketLength(int bucketLength)
public long getCapacity()
public OHCacheBuilder<K,V> capacity(long capacity)
public CacheSerializer<K> getKeySerializer()
public OHCacheBuilder<K,V> keySerializer(CacheSerializer<K> keySerializer)
public CacheSerializer<V> getValueSerializer()
public OHCacheBuilder<K,V> valueSerializer(CacheSerializer<V> valueSerializer)
public int getSegmentCount()
public OHCacheBuilder<K,V> segmentCount(int segmentCount)
public float getLoadFactor()
public OHCacheBuilder<K,V> loadFactor(float loadFactor)
public long getMaxEntrySize()
public OHCacheBuilder<K,V> maxEntrySize(long maxEntrySize)
public ScheduledExecutorService getExecutorService()
public OHCacheBuilder<K,V> executorService(ScheduledExecutorService executorService)
public HashAlgorithm getHashAlgorighm()
public OHCacheBuilder<K,V> hashMode(HashAlgorithm hashMode)
public boolean isThrowOOME()
public OHCacheBuilder<K,V> throwOOME(boolean throwOOME)
Copyright © 2014–2016 Robert Stupp, Koeln, Germany, robert-stupp.de. All rights reserved.