public final class Caches extends Object implements IModule, ICaches
ICaches.Scope
MODULE_NAME
Constructor and Description |
---|
Caches() |
Caches(ICacheConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
清理默认缓存
|
void |
clear(String cacheName)
清理指定名称的缓存
|
void |
close() |
static ICaches |
get() |
Object |
get(Object key)
从默认缓存中获取key对应的对象
|
Object |
get(String cacheName,
Object key)
从指定名称的缓存中获取key对应的对象
|
Map<Object,Object> |
getAll()
从默认缓存中获取所有缓存对象映射
|
Map<Object,Object> |
getAll(String cacheName)
从指定名称的缓存中获取所有缓存对象映射
|
ICacheConfig |
getConfig()
获取缓存配置
|
String |
getName()
获取模块名称
|
IApplication |
getOwner()
获取所属应用容器
|
void |
initialize(IApplication owner)
初始化
|
boolean |
isInitialized()
是否已初始化
|
boolean |
isMultilevel()
是否为Multilevel模式
|
List<?> |
keys()
获取默认缓存中所有key值集合
|
List<?> |
keys(String cacheName)
获取指定名称的缓存中所有key值集合
|
void |
put(Object key,
Object value)
添加对象到默认缓存中
|
void |
put(Object key,
Object value,
int timeout)
添加对象到默认缓存中
|
void |
put(String cacheName,
Object key,
Object value)
添加对象到指定名称的缓存中
|
void |
put(String cacheName,
Object key,
Object value,
int timeout)
添加对象到指定名称的缓存中
|
void |
remove(Object key)
从默认缓存中移除对象
|
void |
remove(String cacheName,
Object key)
从指定名称的缓存中移除对象
|
void |
removeAll(List<?> keys)
批量从默认缓存中移除对象
|
void |
removeAll(String cacheName,
List<?> keys)
批量从指定名称的缓存中移除对象
|
void |
update(Object key,
Object value)
更新对象到默认缓存中
|
void |
update(Object key,
Object value,
int timeout) |
void |
update(String cacheName,
Object key,
Object value)
更新对象到指定名称的缓存中
|
void |
update(String cacheName,
Object key,
Object value,
int timeout)
更新对象到指定名称的缓存中
|
public Caches()
public Caches(ICacheConfig config)
public static ICaches get()
public void initialize(IApplication owner) throws Exception
IInitialization
initialize
in interface IInitialization<IApplication>
owner
- 指定所属容器参数对象Exception
- 初始过程中产生的任何异常public boolean isInitialized()
IInitialization
isInitialized
in interface IInitialization<IApplication>
public void close() throws Exception
close
in interface AutoCloseable
Exception
public IApplication getOwner()
ICaches
public ICacheConfig getConfig()
ICaches
public boolean isMultilevel()
ICaches
isMultilevel
in interface ICaches
public Object get(String cacheName, Object key)
ICaches
public Map<Object,Object> getAll(String cacheName)
ICaches
public Map<Object,Object> getAll()
ICaches
public void put(String cacheName, Object key, Object value)
ICaches
public void put(String cacheName, Object key, Object value, int timeout) throws CacheException
ICaches
put
in interface ICaches
cacheName
- 缓存名称key
- 缓存Keyvalue
- 预缓存的元素对象timeout
- 自定义超时时间(秒),若为0则使用默认值CacheException
- 可能产生的异常public void put(Object key, Object value, int timeout) throws CacheException
ICaches
put
in interface ICaches
key
- 缓存Keyvalue
- 预缓存的元素对象timeout
- 自定义超时时间(秒),若为0则使用默认值CacheException
- 可能产生的异常public void update(String cacheName, Object key, Object value)
ICaches
public void update(String cacheName, Object key, Object value, int timeout) throws CacheException
ICaches
update
in interface ICaches
cacheName
- 缓存名称key
- 缓存Keyvalue
- 缓存元素对象timeout
- 自定义超时时间(秒),若为0则使用默认值CacheException
- 可能产生的异常public void update(Object key, Object value)
ICaches
public void update(Object key, Object value, int timeout) throws CacheException
update
in interface ICaches
CacheException
public List<?> keys(String cacheName)
ICaches
public void remove(String cacheName, Object key)
ICaches
public void removeAll(String cacheName, List<?> keys)
ICaches
public void removeAll(List<?> keys)
ICaches
Copyright © 2022. All rights reserved.