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

com.qingzhuge.framework.cache.provider.CacheProvider Maven / Gradle / Ivy

There is a newer version: 1.0.1.5
Show newest version
package com.qingzhuge.framework.cache.provider;

import com.qingzhuge.framework.cache.Cache;
import com.qingzhuge.framework.cache.CacheChannel;
import com.qingzhuge.framework.cache.CacheExpiredListener;
import com.qingzhuge.framework.cache.autoconfigure.J2CacheProperties;

import java.util.Collection;

/**
 * @author : zero.xiao
 * datetime :2018-06-03 20:22
 * 缓存分级接口定义
 */
public interface CacheProvider {
    /**
     * 缓存的标识名称
     * @return return cache provider name
     */
    String name();

    /**
     * 缓存的层级
     * @return current provider level
     */
    int level();

    /**
     * 确认缓存级别
     * @param level 缓存级别
     * @return 结果
     */
    default boolean level(int level) {
        return (level() & level) != level;
    }

    /**
     * Configure the cache
     *
     * @param regionName the name of the cache region
     * @param listener listener for expired elements
     * @return return cache instance
     */
    Cache buildCache(String regionName, CacheExpiredListener listener);

    /**
     * Configure the cache with timeToLiveInMills
     * @param region cache region name
     * @param timeToLiveInSeconds time to live in second
     * @param listener listener for expired elements
     * @return return cache instance
     */
    Cache buildCache(String region, long timeToLiveInSeconds, CacheExpiredListener listener);

    /**
     * Remove a cache region
     * @param region cache region name
     */
    default void removeCache(String region) {}

    /**
     * Return all channels defined in first level cache
     * @return all regions name
     */
    Collection regions();

    /**
     * Callback to perform any necessary initialization of the underlying cache implementation
     * during SessionFactory construction.
     *
     * @param props current configuration settings.
     */
    void start(J2CacheProperties props);

    /**
     * Callback to perform any necessary cleanup of the underlying cache implementation
     * during SessionFactory.close().
     */
    void stop();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy