All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gate.cache.LazyCache Maven / Gradle / Ivy

There is a newer version: 12.3.1
Show newest version
package gate.cache;

import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

class LazyCache implements Cache
{

	private final Supplier supplier;
	private final AtomicReference value = new AtomicReference<>();

	LazyCache(Supplier supplier)
	{
		this.supplier = supplier;
	}

	@Override
	public T get()
	{
		return value.updateAndGet(e -> e != null ? e : supplier.get());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy