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

org.caffinitas.ohc.CacheLoader Maven / Gradle / Ivy

There is a newer version: 0.7.4
Show newest version
/*
 *      Copyright (C) 2014 Robert Stupp, Koeln, Germany, robert-stupp.de
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package org.caffinitas.ohc;

/**
 * Implementation to load values for cache entries using {@link OHCache#getWithLoader(Object, CacheLoader) getWithLoader}
 * or  {@link OHCache#getWithLoaderAsync(Object, CacheLoader)} getWithLoaderAsynd}.
 *
 * @param  type of the cache key
 * @param  type of the cache value
 */
public interface CacheLoader
{
    /**
     * Cache loaders implement this method and return a non-{@code null} value on success.
     * {@code null} can be returned to indicate that the no value for the requested key could be found.
     * 

* Permanent failures in loading a specific key can be indicated by throwing a {@link PermanentLoadException}. * Other exceptions indicate a temporary failure. *

* * @param key key for the value to load. Always non-{@code null} * @return non-{@code null} value on success or {@code null} if it could not find a value. * @throws PermanentLoadException can be thrown by the loader implementation to indicate that * is will never succeed in finding a value for the requested key. * @throws Exception any exception other than {@link PermanentLoadException} can be thrown by the * loader implementation to indicate a temporary failure in loading the value */ V load(K key) throws PermanentLoadException, Exception; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy