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 divided by number of segments) |
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 |
unlocked |
If set to true , implementations will not perform any locking. The calling code has to take
care of synchronized access. In order to create an instance for a thread-per-core implementation,
set segmentCount=1 , too. |
false |
defaultTTLmillis |
If set to a value > 0 , implementations supporting TTLs will tag all entries with
the given TTL in milliseconds. |
0 |
timeoutsSlots |
The number of timeouts slots for each segment - compare with hashed wheel timer. | 64 |
timeoutsPrecision |
The amount of time in milliseconds for each timeouts-slot. | 128 |
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)
public boolean isUnlocked()
public OHCacheBuilder<K,V> unlocked(boolean unlocked)
public long getDefaultTTLmillis()
public OHCacheBuilder<K,V> defaultTTLmillis(long defaultTTLmillis)
public int getTimeoutsSlots()
public OHCacheBuilder<K,V> timeoutsSlots(int timeoutsSlots)
public int getTimeoutsPrecision()
public OHCacheBuilder<K,V> timeoutsPrecision(int timeoutsPrecision)
Copyright © 2014–2017 Robert Stupp, Koeln, Germany, robert-stupp.de. All rights reserved.