Class SimpleCacheTemplate
-
- All Implemented Interfaces:
public class SimpleCacheTemplate<T>only support raw and method argument key. NOT support SpEL or KeyGenerator
should declare it as a final field to enhance performance, then use it after application context has started
- Since:
2024-06-25
trydofor
-
-
Constructor Summary
Constructors Constructor Description SimpleCacheTemplate(String manager, Array<String> caches)SimpleCacheTemplate(Array<Cache> caches)
-
Method Summary
Modifier and Type Method Description Array<Cache>getCaches()Converter<T, Object>getEncoder()SimpleCacheTemplate<T>setEncoder(@Nullable() Converter<T, Object> encoder)encode Value to Cache, default null Converter<Object, T>getDecoder()SimpleCacheTemplate<T>setDecoder(@Nullable() Converter<Object, T> decoder)decode Value from Cache, default null BeanFactorygetBeanFactory()SimpleCacheTemplate<T>setBeanFactory(BeanFactory beanFactory)set the application context to re-init Cache by CacheManager bean. TgetArgKey(@NotNull() Array<Object> args)get and decode Value from cache by argument key TgetRawKey(@NotNull() Object key)get and decode Value from cache by raw key TgetArgKey(@NotNull() Supplier<T> value, @NotNull() Array<Object> args)get and decode Value from cache by argument key, put the non-null value if no cache found. TgetRawKey(@NotNull() Supplier<T> value, @NotNull() Object key)get and decode Value from cache by raw key, put the non-null value if no cache found. <U> UgetArgKey(@NotNull() Converter<T, U> converter, @NotNull() Array<Object> args)get, decode and convert Value from cache by argument key, put the non-null value if no cache found. <U> UgetRawKey(@NotNull() Converter<T, U> converter, @NotNull() Object key)get, decode and convert Value from cache by raw key, put the non-null value if no cache found. <U> UgetArgKey(@NotNull() Converter<T, U> converter, @NotNull() Supplier<T> value, @NotNull() Array<Object> args)get, decode and convert Value from cache by argument key, put the non-null value if no cache found. <U> UgetRawKey(@NotNull() Converter<T, U> converter, @NotNull() Supplier<T> value, @NotNull() Object key)get, decode and convert Value from cache by raw key, put the non-null value if no cache found. voidputArgKey(@NotNull() T value, @NotNull() Array<Object> args)voidputRawKey(@NotNull() T value, @NotNull() Object key)TputArgKeyIfPresent(@NotNull() T value, @NotNull() Array<Object> args)encode and put value to cache, return the decoded existing Value TputRawKeyIfPresent(@NotNull() T value, @NotNull() Object key)encode and put value to cache, return the decoded existing Value <U> UputArgKeyIfPresent(@NotNull() Converter<T, U> converter, @NotNull() T value, @NotNull() Array<Object> args)encode and put value to cache, return the decoded and converted existing Value <U> UputRawKeyIfPresent(@NotNull() Converter<T, U> converter, @NotNull() T value, @NotNull() Object key)encode and put value to cache, return the decoded and converted existing Value voidevictArgKey(@NotNull() Array<Object> args)voidevictRawKey(@NotNull() Object key)voidevictAll()Tdecode(Object obj)decode value from cache, force to cast type if the decoder is null Objectencode(T obj)encode value to cache if the encoder not null ObjectrawKey(Array<Object> args)generate raw key by args/parmas -
-
Method Detail
-
getEncoder
Converter<T, Object> getEncoder()
-
setEncoder
@Contract(value = "_->this") SimpleCacheTemplate<T> setEncoder(@Nullable() Converter<T, Object> encoder)
encode Value to Cache, default null
-
getDecoder
Converter<Object, T> getDecoder()
-
setDecoder
@Contract(value = "_->this") SimpleCacheTemplate<T> setDecoder(@Nullable() Converter<Object, T> decoder)
decode Value from Cache, default null
-
getBeanFactory
BeanFactory getBeanFactory()
-
setBeanFactory
@Contract(value = "_->this") SimpleCacheTemplate<T> setBeanFactory(BeanFactory beanFactory)
set the application context to re-init Cache by CacheManager bean. mostly for unit test to avoid multiple application context.
-
getArgKey
T getArgKey(@NotNull() Array<Object> args)
get and decode Value from cache by argument key
-
getArgKey
T getArgKey(@NotNull() Supplier<T> value, @NotNull() Array<Object> args)
get and decode Value from cache by argument key, put the non-null value if no cache found.
-
getRawKey
T getRawKey(@NotNull() Supplier<T> value, @NotNull() Object key)
get and decode Value from cache by raw key, put the non-null value if no cache found.
-
getArgKey
<U> U getArgKey(@NotNull() Converter<T, U> converter, @NotNull() Array<Object> args)
get, decode and convert Value from cache by argument key, put the non-null value if no cache found.
-
getRawKey
<U> U getRawKey(@NotNull() Converter<T, U> converter, @NotNull() Object key)
get, decode and convert Value from cache by raw key, put the non-null value if no cache found.
-
getArgKey
<U> U getArgKey(@NotNull() Converter<T, U> converter, @NotNull() Supplier<T> value, @NotNull() Array<Object> args)
get, decode and convert Value from cache by argument key, put the non-null value if no cache found.
-
getRawKey
<U> U getRawKey(@NotNull() Converter<T, U> converter, @NotNull() Supplier<T> value, @NotNull() Object key)
get, decode and convert Value from cache by raw key, put the non-null value if no cache found.
-
putArgKeyIfPresent
T putArgKeyIfPresent(@NotNull() T value, @NotNull() Array<Object> args)
encode and put value to cache, return the decoded existing Value
-
putRawKeyIfPresent
T putRawKeyIfPresent(@NotNull() T value, @NotNull() Object key)
encode and put value to cache, return the decoded existing Value
-
putArgKeyIfPresent
<U> U putArgKeyIfPresent(@NotNull() Converter<T, U> converter, @NotNull() T value, @NotNull() Array<Object> args)
encode and put value to cache, return the decoded and converted existing Value
-
putRawKeyIfPresent
<U> U putRawKeyIfPresent(@NotNull() Converter<T, U> converter, @NotNull() T value, @NotNull() Object key)
encode and put value to cache, return the decoded and converted existing Value
-
evictArgKey
void evictArgKey(@NotNull() Array<Object> args)
-
evictRawKey
void evictRawKey(@NotNull() Object key)
-
evictAll
void evictAll()
-
-
-
-