RedisCacheBuilder extends BaseCacheBuilder { @SuppressWarnings("unchecked") public <K, V> RedisCache<K, V> build() { Client client = new MultiRedisClient(hostName, port, concurrencyLevel); return new RedisCache<>(name, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, serializer, client); } RedisCacheBuilder(); RedisCacheBuilder name(final String name); @SuppressWarnings("unchecked") RedisCacheBuilder cacheLoader(final CacheLoader<K, V> cacheLoader); @SuppressWarnings("unchecked") RedisCacheBuilder evictionListener(final EvictionListener<K, V> evictionListener); RedisCacheBuilder serializer(final Serializer<Object> serializer); RedisCacheBuilder hostName(final String hostName); RedisCacheBuilder port(final int port); RedisCacheBuilder concurrencyLevel(int concurrencyLevel); @SuppressWarnings("unchecked") RedisCache<K, V> build(); @SuppressWarnings("unchecked") RedisCache<K, V> build(final String cacheName);  }
@Test public void build() { Cache<Object, Object> cache = CacheBuilder.redisCache() .cacheLoader(BaseCacheBuilder.DEFAULT_CACHE_LOADER) .evictionListener(BaseCacheBuilder.DEFAULT_EVICTION_LISTENER) .serializer(BaseCacheBuilder.DEFAULT_SERIALIZER) .hostName("localhost").port(6379).concurrencyLevel(2).build(); assertTrue(cache instanceof RedisCache); }