Class MapSingleUseObjectProvider

java.lang.Object
org.keycloak.models.map.singleUseObject.MapSingleUseObjectProvider
All Implemented Interfaces:
SingleUseObjectProvider, Provider

public class MapSingleUseObjectProvider extends Object implements SingleUseObjectProvider
Author:
Martin Kanis
  • Field Details

  • Constructor Details

  • Method Details

    • put

      public void put(String key, long lifespanSeconds, Map<String,String> notes)
      Description copied from interface: SingleUseObjectProvider
      Stores the given data and guarantees that data should be available in the store for at least the time specified by parameter
      Specified by:
      put in interface SingleUseObjectProvider
    • get

      public Map<String,String> get(String key)
      Description copied from interface: SingleUseObjectProvider
      Gets data associated with the given key.
      Specified by:
      get in interface SingleUseObjectProvider
      Parameters:
      key - String
      Returns:
      Map<String, String> Data associated with the given key or null if there is no associated data.
    • remove

      public Map<String,String> remove(String key)
      Description copied from interface: SingleUseObjectProvider
      This method returns data just if removal was successful. Implementation should guarantee that "remove" is single-use. So if 2 threads (even on different cluster nodes or on different cross-dc nodes) calls "remove(123)" concurrently, then just one of them is allowed to succeed and return data back. It can't happen that both will succeed.
      Specified by:
      remove in interface SingleUseObjectProvider
      Returns:
      context data associated to the key. It returns null if there are no context data available.
    • replace

      public boolean replace(String key, Map<String,String> notes)
      Description copied from interface: SingleUseObjectProvider
      Replaces data associated with the given key in the store if the store contains the key.
      Specified by:
      replace in interface SingleUseObjectProvider
      Parameters:
      key - String
      notes - Map<String, String> New data to be stored
      Returns:
      true if the store contains the key and data was replaced, otherwise false.
    • putIfAbsent

      public boolean putIfAbsent(String key, long lifespanInSeconds)
      Description copied from interface: SingleUseObjectProvider
      Will try to put the key into the cache. It will succeed just if key is not already there.
      Specified by:
      putIfAbsent in interface SingleUseObjectProvider
      lifespanInSeconds - Minimum lifespan for which successfully added key will be kept in the cache.
      Returns:
      true if the key was successfully put into the cache. This means that same key wasn't in the cache before
    • contains

      public boolean contains(String key)
      Description copied from interface: SingleUseObjectProvider
      Checks if there is a record in the store for the given key.
      Specified by:
      contains in interface SingleUseObjectProvider
      Parameters:
      key - String
      Returns:
      true if the record is present in the store, false otherwise.
    • close

      public void close()
      Specified by:
      close in interface Provider