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

org.opendaylight.infrautils.caches.CacheProvider Maven / Gradle / Ivy

/*
 * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.infrautils.caches;

/**
 * Provider (AKA factory) of {@link Cache}s.
 *
 * 

Users typically obtain an implementation of this from the OSGi service registry. * *

{@link Cache} instances produced by this service are neither transactional, * nor distributed, nor persistent. * *

Implementations of this interface are expected to be thread-safe. * * @author Michael Vorburger.ch */ public interface CacheProvider { // In the future there could be other such interfaces // imagine a ClusteredCacheProvider or a TxCacheProvider, which could return // Cache instances which are that, if there was a need for it - but currently there is not- /** * Creates a brand new {@link Cache} (API with unchecked exceptions), based on the passed configuration and policy. * It is the caller's responsibility to {@link Cache#close()} a Cache obtained from this when they stop. */ Cache newCache(CacheConfig cacheConfig, CachePolicy initialPolicy); /** * Creates a brand new {@link Cache} (API with unchecked exceptions), based on * the passed configuration and a default policy. * It is the caller's responsibility to {@link Cache#close()} a Cache obtained from this when they stop. */ default Cache newCache(CacheConfig cacheConfig) { return newCache(cacheConfig, new CachePolicyBuilder().build()); } /** * Creates a brand new {@link CheckedCache} (API for checked exceptions), based * on the passed configuration and policy. * It is the caller's responsibility to {@link Cache#close()} a Cache obtained from this when they stop. */ CheckedCache newCheckedCache( CheckedCacheConfig cacheConfig, CachePolicy initialPolicy); /** * Creates a brand new {@link CheckedCache} (API for checked exceptions), based * on the passed configuration and a default policy. * It is the caller's responsibility to {@link Cache#close()} a Cache obtained from this when they stop. */ default CheckedCache newCheckedCache(CheckedCacheConfig cacheConfig) { return newCheckedCache(cacheConfig, new CachePolicyBuilder().build()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy