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

ch.inftec.ju.util.collection.Caches Maven / Gradle / Ivy

There is a newer version: 6.1-4
Show newest version
package ch.inftec.ju.util.collection;

import ch.inftec.ju.util.function.Function;

/**
 * Factory class to create Cache instances.
 *
 */
public class Caches {
	/**
	 * Returns a simpel, thread safe Cache implementation with a maximum size and an getter function to create values for keys not
	 * available in the cache yet / anymore.
	 * @param maxSize Maximum size of the cache. If reached, the longest unused value will be removed
	 * @param unknownValueGetter Function to create values for keys not stored in the Cache
	 * @param  Key type
	 * @param  Value type
	 * @return Cache implementation
	 */
	public static  Cache simpleBoundedCache(int maxSize, Function unknownValueGetter) {
		return new SimpleCache<>(maxSize, unknownValueGetter);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy