Class LockedAbstractCache<K,V>

java.lang.Object
io.github.xanthic.cache.core.LockedAbstractCache<K,V>
Type Parameters:
K - The type of keys that form the cache
V - The type of values contained in the cache
All Implemented Interfaces:
io.github.xanthic.cache.api.Cache<K,V>

@Deprecated public abstract class LockedAbstractCache<K,V> extends Object implements io.github.xanthic.cache.api.Cache<K,V>
Deprecated.
no longer used by Xanthic to implement any canonical cache provider
Safely implements Cache methods using ReadWriteLock.

This abstraction allows for underlying cache providers to implement the Cache interface in a thread-safe manner, even if the underlying cache does not already implement the more "exotic" write methods required by the Cache contract.

As this abstraction has a performance hit, it should be avoided if the backing cache provider already provides an implementation for these methods.

Does not support null values.

  • Field Details

  • Constructor Details

    • LockedAbstractCache

      public LockedAbstractCache()
      Deprecated.
  • Method Details

    • get

      public V get(@NotNull K key)
      Deprecated.
      Specified by:
      get in interface io.github.xanthic.cache.api.Cache<K,V>
    • put

      public V put(@NotNull K key, @NotNull V value)
      Deprecated.
      Specified by:
      put in interface io.github.xanthic.cache.api.Cache<K,V>
    • remove

      public V remove(@NotNull K key)
      Deprecated.
      Specified by:
      remove in interface io.github.xanthic.cache.api.Cache<K,V>
    • clear

      public void clear()
      Deprecated.
      Specified by:
      clear in interface io.github.xanthic.cache.api.Cache<K,V>
    • size

      public long size()
      Deprecated.
      Specified by:
      size in interface io.github.xanthic.cache.api.Cache<K,V>
    • compute

      public V compute(@NotNull K key, @NotNull @NotNull BiFunction<? super K,? super V,? extends V> computeFunc)
      Deprecated.
      Specified by:
      compute in interface io.github.xanthic.cache.api.Cache<K,V>
    • computeIfAbsent

      public V computeIfAbsent(@NotNull K key, @NotNull @NotNull Function<K,V> computeFunc)
      Deprecated.
      Specified by:
      computeIfAbsent in interface io.github.xanthic.cache.api.Cache<K,V>
    • computeIfPresent

      public V computeIfPresent(@NotNull K key, @NotNull @NotNull BiFunction<? super K,? super V,? extends V> computeFunc)
      Deprecated.
      Specified by:
      computeIfPresent in interface io.github.xanthic.cache.api.Cache<K,V>
    • putIfAbsent

      public V putIfAbsent(@NotNull K key, @NotNull V value)
      Deprecated.
      Specified by:
      putIfAbsent in interface io.github.xanthic.cache.api.Cache<K,V>
    • merge

      public V merge(@NotNull K key, @NotNull V value, @NotNull @NotNull BiFunction<V,V,V> mergeFunc)
      Deprecated.
      Specified by:
      merge in interface io.github.xanthic.cache.api.Cache<K,V>
    • replace

      public boolean replace(@NotNull K key, @NotNull V value)
      Deprecated.
      Specified by:
      replace in interface io.github.xanthic.cache.api.Cache<K,V>
    • replace

      public boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue)
      Deprecated.
      Specified by:
      replace in interface io.github.xanthic.cache.api.Cache<K,V>
    • putAll

      public void putAll(@NotNull @NotNull Map<? extends K,? extends V> map)
      Deprecated.
      Specified by:
      putAll in interface io.github.xanthic.cache.api.Cache<K,V>
    • getUnlocked

      @Nullable protected abstract V getUnlocked(@NotNull K key)
      Deprecated.
    • putUnlocked

      protected abstract void putUnlocked(@NotNull K key, @NotNull V value)
      Deprecated.
    • removeUnlocked

      protected abstract void removeUnlocked(@NotNull K key)
      Deprecated.
    • clearUnlocked

      protected abstract void clearUnlocked()
      Deprecated.
    • sizeUnlocked

      protected abstract long sizeUnlocked()
      Deprecated.
    • read

      protected <T> T read(Supplier<T> reader)
      Deprecated.
    • write

      protected <T> T write(Supplier<T> writer)
      Deprecated.