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

com.qingzhuge.framework.cache.Cache Maven / Gradle / Ivy

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

import java.util.Collection;

/**
 * @author :zero.xiao
 * datetime :2018/1/14 16:02
 * cache 基本接口
 **/
public interface Cache {
    /**
     * 获取缓存
     *
     * @param key cache key
     * @return the cached object or null
     */
    Object get(String key) ;

    /**
     * 判断缓存是否存在
     * @param key cache key
     * @return true if key exists
     */
    default boolean exists(String key) {
        return get(key) != null;
    }

    /**
     * 添加缓存
     *
     * @param key cache key
     * @param value cache value
     */
    void put(String key, Object value);

    /**
     * 获得所有的key
     *
     * @return 返回键的集合
     */
    Collection keys() ;

    /**
     * 删除多个key
     *
     * @param keys Cache key
     */
    void evict(String...keys);

    /**
     * 清除所有的缓存
     */
    void clear();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy