- protected InMemorySchemaSourceCache(final SchemaSourceRegistry consumer, final Class<T> representation, final int maxSize) {
- super(consumer, representation, Costs.IMMEDIATE);
- cache = CacheBuilder.newBuilder().softValues().maximumSize(maxSize).removalListener(LISTENER).build();
+ public static <R extends SchemaSourceRepresentation> InMemorySchemaSourceCache<R> createSoftCache(
+ final SchemaSourceRegistry consumer, final Class<R> representation, final long lifetime,
+ final TimeUnit units) {
+ return new InMemorySchemaSourceCache<>(consumer, representation, CacheBuilder.newBuilder().softValues()
+ .expireAfterAccess(lifetime, units));