@Test public void build() { OffHeapByteBufferStore bufferStore = new OffHeapByteBufferStore(8388608, 10); Cache<Object, Object> cache = CacheBuilder.versionedOffHeapCache().storage(bufferStore) .cacheLoader(BaseCacheBuilder.DEFAULT_CACHE_LOADER) .evictionListener(BaseCacheBuilder.DEFAULT_EVICTION_LISTENER) .indexHandler(DummyIndexHandler.getInstance()) .addIndex("age", IndexType.RANGE_INDEX).serializer(BaseCacheBuilder.DEFAULT_SERIALIZER) .bufferCleanerPeriod(100).bufferCleanerThreshold(0.6f).concurrencyLevel(10) .evictionPeriod(100).build(); assertTrue(cache instanceof SearchableCache); assertTrue(cache instanceof VersionedOffHeapCache); }
@SuppressWarnings("unchecked") public <K, V> VersionedOffHeapCache build() { if (this.byteBufferStore == null) { throw new NecessaryArgumentException("ByteBufferStore must be set!"); } return new VersionedOffHeapCache<>(name, byteBufferStore, (Serializer<V>) serializer, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, (IndexHandler<K, V>) indexHandler, bufferCleanerPeriod, bufferCleanerThreshold, concurrencyLevel, evictionPeriod); }
VersionedOffHeapCacheBuilder extends BaseCacheBuilder { @SuppressWarnings("unchecked") public <K, V> VersionedOffHeapCache build() { if (this.byteBufferStore == null) { throw new NecessaryArgumentException("ByteBufferStore must be set!"); } return new VersionedOffHeapCache<>(name, byteBufferStore, (Serializer<V>) serializer, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, (IndexHandler<K, V>) indexHandler, bufferCleanerPeriod, bufferCleanerThreshold, concurrencyLevel, evictionPeriod); } }
VersionedOffHeapCacheBuilder extends BaseCacheBuilder { @SuppressWarnings("unchecked") public <K, V> VersionedOffHeapCache build() { if (this.byteBufferStore == null) { throw new NecessaryArgumentException("ByteBufferStore must be set!"); } return new VersionedOffHeapCache<>(name, byteBufferStore, (Serializer<V>) serializer, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, (IndexHandler<K, V>) indexHandler, bufferCleanerPeriod, bufferCleanerThreshold, concurrencyLevel, evictionPeriod); } VersionedOffHeapCacheBuilder(); }
VersionedOffHeapCacheBuilder extends BaseCacheBuilder { @SuppressWarnings("unchecked") public <K, V> VersionedOffHeapCache build() { if (this.byteBufferStore == null) { throw new NecessaryArgumentException("ByteBufferStore must be set!"); } return new VersionedOffHeapCache<>(name, byteBufferStore, (Serializer<V>) serializer, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, (IndexHandler<K, V>) indexHandler, bufferCleanerPeriod, bufferCleanerThreshold, concurrencyLevel, evictionPeriod); } VersionedOffHeapCacheBuilder(); VersionedOffHeapCacheBuilder name(final String name); VersionedOffHeapCacheBuilder storage(final OffHeapByteBufferStore bufferStore); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder serializer(final Serializer<V> serializer); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder cacheLoader(final CacheLoader<K, V> cacheLoader); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder evictionListener(
      final EvictionListener<K, V> evictionListener); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder indexHandler(final IndexHandler<K, V> indexHandler); VersionedOffHeapCacheBuilder concurrencyLevel(final int concurrencyLevel); VersionedOffHeapCacheBuilder evictionPeriod(final long evictionPeriod); VersionedOffHeapCacheBuilder bufferCleanerPeriod(final long bufferCleanerPeriod); VersionedOffHeapCacheBuilder bufferCleanerThreshold(final float bufferCleanerThreshold); synchronized VersionedOffHeapCacheBuilder addIndex(final String attributeName,
      final IndexType indexType); @SuppressWarnings("unchecked") VersionedOffHeapCache build(); @SuppressWarnings("unchecked") VersionedOffHeapCache build(final String name); }
VersionedOffHeapCacheBuilder extends BaseCacheBuilder { @SuppressWarnings("unchecked") public <K, V> VersionedOffHeapCache build() { if (this.byteBufferStore == null) { throw new NecessaryArgumentException("ByteBufferStore must be set!"); } return new VersionedOffHeapCache<>(name, byteBufferStore, (Serializer<V>) serializer, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, (IndexHandler<K, V>) indexHandler, bufferCleanerPeriod, bufferCleanerThreshold, concurrencyLevel, evictionPeriod); } VersionedOffHeapCacheBuilder(); VersionedOffHeapCacheBuilder name(final String name); VersionedOffHeapCacheBuilder storage(final OffHeapByteBufferStore bufferStore); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder serializer(final Serializer<V> serializer); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder cacheLoader(final CacheLoader<K, V> cacheLoader); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder evictionListener(
      final EvictionListener<K, V> evictionListener); @SuppressWarnings("unchecked") VersionedOffHeapCacheBuilder indexHandler(final IndexHandler<K, V> indexHandler); VersionedOffHeapCacheBuilder concurrencyLevel(final int concurrencyLevel); VersionedOffHeapCacheBuilder evictionPeriod(final long evictionPeriod); VersionedOffHeapCacheBuilder bufferCleanerPeriod(final long bufferCleanerPeriod); VersionedOffHeapCacheBuilder bufferCleanerThreshold(final float bufferCleanerThreshold); synchronized VersionedOffHeapCacheBuilder addIndex(final String attributeName,
      final IndexType indexType); @SuppressWarnings("unchecked") VersionedOffHeapCache build(); @SuppressWarnings("unchecked") VersionedOffHeapCache build(final String name);  }