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

    Author:

    trydofor

    • Constructor Detail

      • SimpleCacheTemplate

        SimpleCacheTemplate(Array<Cache> caches)
    • Method Detail

      • 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.

      • getRawKey

         T getRawKey(@NotNull() Object key)

        get and decode Value from cache by raw 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

      • decode

         T decode(Object obj)

        decode value from cache, force to cast type if the decoder is null

      • encode

         Object encode(T obj)

        encode value to cache if the encoder not null