Class CacheServiceImpl
java.lang.Object
net.wenzuo.atom.redis.service.impl.CacheServiceImpl
- All Implemented Interfaces:
CacheService
@ConditionalOnProperty(value="atom.redis.cache-service",
matchIfMissing=true)
public class CacheServiceImpl
extends Object
implements CacheService
- Since:
- 2025-01-03
- Author:
- Catch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存 此方法支持嵌套类型的缓存, 如List<User><T> T缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存<T> T缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存 此方法支持嵌套类型的缓存, 如List<User><T> T缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存void从缓存中移除指定 key 的值voidevict(Collection<String> keys) 从缓存中移除指定多个 key 的值void从缓存中移除所有匹配指定模式的 key 的值<T> T缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存, 此方法中 key 用不过期 此方法支持嵌套类型的缓存, 如List<User><T> T缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存, 此方法中 key 用不过期
-
Constructor Details
-
CacheServiceImpl
public CacheServiceImpl()
-
-
Method Details
-
cache
Description copied from interface:CacheService缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存- Specified by:
cachein interfaceCacheService- Parameters:
key- 缓存键supplier- 缓存值的提供者target- 缓存值的类型- Returns:
- 缓存的值
-
cache
Description copied from interface:CacheService缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存- Specified by:
cachein interfaceCacheService- Parameters:
key- 缓存键supplier- 缓存值的提供者timeout- 缓存值的过期时间, 为 null 则使用默认过期时间target- 缓存值的类型- Returns:
- 缓存的值
-
cache
Description copied from interface:CacheService缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存 此方法支持嵌套类型的缓存, 如List<User>- Specified by:
cachein interfaceCacheService- Parameters:
key- 缓存键supplier- 缓存值的提供者wrapper- 缓存值的包装类inners- 缓存值的内部类- Returns:
- 缓存的值
-
cache
public <T> T cache(String key, Supplier<T> supplier, Duration timeout, Class<?> wrapper, Class<?>... inners) Description copied from interface:CacheService缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存 此方法支持嵌套类型的缓存, 如List<User>- Specified by:
cachein interfaceCacheService- Parameters:
key- 缓存键supplier- 缓存值的提供者timeout- 缓存值的过期时间, 为 null 则使用默认过期时间wrapper- 缓存值的包装类inners- 缓存值的内部类- Returns:
- 缓存的值
-
keep
Description copied from interface:CacheService缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存, 此方法中 key 用不过期- Specified by:
keepin interfaceCacheService- Parameters:
key- 缓存键supplier- 缓存值的提供者target- 缓存值的类型- Returns:
- 缓存的值
-
keep
Description copied from interface:CacheService缓存指定 key 的值,如果缓存中不存在,则使用 supplier 函数获取并缓存, 此方法中 key 用不过期 此方法支持嵌套类型的缓存, 如List<User>- Specified by:
keepin interfaceCacheService- Parameters:
key- 缓存键supplier- 缓存值的提供者wrapper- 缓存值的包装类inners- 缓存值的内部类- Returns:
- 缓存的值
-
evict
Description copied from interface:CacheService从缓存中移除指定 key 的值- Specified by:
evictin interfaceCacheService- Parameters:
key- 缓存键
-
evict
Description copied from interface:CacheService从缓存中移除指定多个 key 的值- Specified by:
evictin interfaceCacheService- Parameters:
keys- 缓存键集合
-
evictAll
Description copied from interface:CacheService从缓存中移除所有匹配指定模式的 key 的值匹配示例:
h?llo matches hello, hallo and hxllo
h*llo matches hllo and heeeello
h[ae]llo matches hello and hallo, but not hillo
h[^e]llo matches hallo, hbllo, ... but not hello
h[a-b]llo matches hallo and hbllo
- Specified by:
evictAllin interfaceCacheService- Parameters:
pattern- 匹配模式
-