public class CacheUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
defaultCacheName |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
clear()
清空缓存
|
static void |
clear(String name)
清空缓存
|
static Object |
get(String key)
获取缓存数据
|
static <T> T |
get(String key,
Class<T> type)
获取缓存数据
|
static <T> T |
get(String key,
Class<T> type,
T defaultValue)
获取缓存数据
|
static Object |
get(String key,
Object defaultValue)
获取缓存数据
|
static <T> T |
get(String name,
String key,
Class<T> type,
T defaultValue)
获取缓存数据
|
static Object |
get(String name,
String key,
Object defaultValue)
获取缓存数据
|
static org.springframework.cache.Cache |
getCache()
获取默认缓存
|
static org.springframework.cache.Cache |
getCache(String name)
获取缓存
|
static org.springframework.cache.CacheManager |
getCacheManager()
获取缓存管理器
|
static <T> T |
getOrSet(String key,
Class<T> type,
long ttl,
java.util.function.Supplier<T> setIfAbsent)
获取缓存,不存在则设置
|
static Object |
getOrSet(String key,
long ttl,
java.util.function.Supplier<Object> setIfAbsent)
获取缓存,不存在则设置
|
static <T> T |
getOrSet(String name,
String key,
Class<T> type,
long ttl,
java.util.function.Supplier<T> setIfAbsent)
获取缓存,不存在则设置
|
static boolean |
has(String key)
缓存键是否存在
|
static boolean |
has(String name,
String key)
缓存键是否存在
|
static void |
put(String key,
Object value)
设置缓存
|
static void |
put(String key,
Object value,
long ttl)
设置缓存
|
static void |
put(String name,
String key,
Object value,
long ttl)
设置缓存
|
static void |
remove(String key)
删除缓存
|
static void |
remove(String name,
String key)
删除缓存
|
public static String defaultCacheName
@Nullable public static org.springframework.cache.CacheManager getCacheManager()
@Nullable public static org.springframework.cache.Cache getCache(String name)
name - 缓存名称@Nullable public static org.springframework.cache.Cache getCache()
@Nullable public static <T> T get(String name, String key, Class<T> type, @Nullable T defaultValue)
name - 缓存名称key - 缓存键defaultValue - 默认值@Nullable public static Object get(String name, String key, @Nullable Object defaultValue)
name - 缓存名称key - 缓存键defaultValue - 默认值@Nullable public static Object get(String key, @Nullable Object defaultValue)
key - 缓存键defaultValue - 默认值@Nullable public static <T> T get(String key, Class<T> type, @Nullable T defaultValue)
T - 值类型key - 缓存键type - 值类型defaultValue - 默认值@Nullable public static <T> T get(String key, Class<T> type)
T - 值类型key - 缓存键type - 值类型@Nullable public static <T> T getOrSet(String name, String key, Class<T> type, long ttl, @Nullable java.util.function.Supplier<T> setIfAbsent)
T - 值类型name - 缓存名称key - 缓存键type - 值类型ttl - 存活时间(毫秒), 0 则不限时setIfAbsent - 不存在获取数据函数@Nullable public static <T> T getOrSet(String key, Class<T> type, long ttl, @Nullable java.util.function.Supplier<T> setIfAbsent)
T - 值类型key - 缓存键type - 值类型ttl - 存活时间(毫秒), 0 则不限时setIfAbsent - 不存在获取数据函数@Nullable public static Object getOrSet(String key, long ttl, @Nullable java.util.function.Supplier<Object> setIfAbsent)
key - 缓存键ttl - 存活时间(毫秒), 0 则不限时setIfAbsent - 不存在获取数据函数public static void put(String name, String key, @Nullable Object value, long ttl)
name - 缓存名称key - 缓存键value - 缓存值ttl - 存活时间(毫秒), 0 则不限时public static void put(String key, @Nullable Object value, long ttl)
key - 缓存键value - 缓存值ttl - 存活时间(毫秒), 0 则不限时public static boolean has(String name, String key)
name - 缓存名称key - 缓存键public static boolean has(String key)
key - 缓存键public static void remove(String key)
key - 缓存键public static void clear(String name)
name - 缓存名称public static void clear()
Copyright © 2024. All rights reserved.