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

com.hazelcast.internal.nearcache.NearCacheManager Maven / Gradle / Ivy

/*
 * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
 *
 * 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 com.hazelcast.internal.nearcache;

import com.hazelcast.config.NearCacheConfig;
import com.hazelcast.internal.adapter.DataStructureAdapter;

import java.util.Collection;

/**
 * {@link NearCacheManager} is the contract point to manage all existing {@link NearCache} instances.
 */
public interface NearCacheManager {

    /**
     * Gets the {@link NearCache} instance associated with given {@code name}.
     *
     * @param name the name of the {@link NearCache} instance will be got
     * @param   the type of the key for Near Cache
     * @param   the type of the value for Near Cache
     * @return the {@link NearCache} instance
     * associated with given {@code name}
     */
     NearCache getNearCache(String name);

    /**
     * Creates a new {@link NearCache} with given configurations
     * or returns existing one.
     *
     * @param name            the name of the {@link NearCache} to be created or existing one
     * @param nearCacheConfig the {@link NearCacheConfig} of the {@link NearCache} to be created
     * @param              the key type of the {@link NearCache}
     * @param              the value type of the {@link NearCache}
     * @return the created or existing {@link NearCache} instance associated with given {@code name}
     */
     NearCache getOrCreateNearCache(String name, NearCacheConfig nearCacheConfig);

    /**
     * Creates a new {@link NearCache} with given configurations or returns existing one.
     *
     * Triggers the pre-loading of the created {@link NearCache} via the supplied {@link DataStructureAdapter}.
     *
     * @param name                 the name of the {@link NearCache}
     *                             to be created or existing one
     * @param nearCacheConfig      the {@link NearCacheConfig} of the {@link NearCache} to be created
     * @param dataStructureAdapter the {@link DataStructureAdapter} of the {@link NearCache} to be created
     * @param                   the key type of the {@link NearCache}
     * @param                   the value type of the {@link NearCache}
     * @return the created or existing {@link NearCache} instance associated with given {@code name}
     */
     NearCache getOrCreateNearCache(String name,
                                                NearCacheConfig nearCacheConfig,
                                                DataStructureAdapter dataStructureAdapter);

    /**
     * Lists all existing {@link NearCache} instances.
     *
     * @return all existing {@link NearCache} instances
     */
    Collection listAllNearCaches();

    /**
     * Clears {@link NearCache} instance associated with given {@code name} but not removes it.
     *
     * @param name name of the {@link NearCache} to be cleared
     * @return {@code true} if {@link NearCache} was found and cleared, {@code false} otherwise
     */
    boolean clearNearCache(String name);

    /**
     * Clears all defined {@link NearCache} instances.
     */
    void clearAllNearCaches();

    /**
     * Destroys {@link NearCache} instance associated with given {@code name} and also removes it.
     *
     * @param name name of the {@link NearCache} to be destroyed
     * @return {@code true} if {@link NearCache} was found and destroyed, {@code false} otherwise
     */
    boolean destroyNearCache(String name);

    /**
     * Destroys all defined {@link NearCache} instances.
     */
    void destroyAllNearCaches();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy