Class DatastoreService

java.lang.Object
fr.paris.lutece.portal.service.datastore.DatastoreService

public final class DatastoreService extends Object
Datastore Service
  • Field Details

  • Method Details

    • evictCachedKey

      public static void evictCachedKey(String strKey)
      Drop a key from the cache, whether it held a value or the missing marker Called by DataEntityHome on every write so a caller that stores an entity through the home rather than through this service does not leave a stale entry behind.
      Parameters:
      strKey - The entity's key
    • init

      public static void init()
      initialize the service
    • getDataValue

      public static String getDataValue(String strKey, String strDefault)
      Get entity
      Parameters:
      strKey - The entity's key
      strDefault - The default value
      Returns:
      The value
    • getInstanceDataValue

      public static String getInstanceDataValue(String strKey, String strDefault)
      Get entity depending the current web app instance
      Parameters:
      strKey - The entity's key
      strDefault - The default value
      Returns:
      The value
    • setDataValue

      public static void setDataValue(String strKey, String strValue)
      Set entity
      Parameters:
      strKey - The entity's key
      strValue - The value
    • setInstanceDataValue

      public static void setInstanceDataValue(String strKey, String strValue)
      Set entity depending the current web app instance
      Parameters:
      strKey - The entity's key
      strValue - The value
    • insertDataValueIfAbsent

      public static boolean insertDataValueIfAbsent(String strKey, String strValue)
      Atomically sets a value only if the key does not already exist in the datastore. Safe under concurrent calls from multiple application instances (multi-instance deployment) — relies on the database-level primary key uniqueness of core_datastore.entity_key.

      Unlike setDataValue(String, String) which performs an upsert (and therefore overwrites the existing value), this method never overwrites. Use it for one-shot initialization of cluster-shared values (RSA keys, cluster tokens, ...).

      Parameters:
      strKey - The entity's key
      strValue - The value to insert if the key is absent
      Returns:
      true if the value was stored, false if the key already existed (in which case the stored value is left untouched)
      Since:
      8.0
    • removeData

      public static void removeData(String strKey)
      Remove a give key
      Parameters:
      strKey - The key
    • removeInstanceData

      public static void removeInstanceData(String strKey)
      Remove a give key depending the current web app instance
      Parameters:
      strKey - The key
    • removeDataByPrefix

      public static void removeDataByPrefix(String strPrefix)
      Remove all data where keys begin with a given prefix
      Parameters:
      strPrefix - The prefix
    • removeInstanceDataByPrefix

      public static void removeInstanceDataByPrefix(String strPrefix)
      Remove all data where keys begin with a given prefix depending the current web app instance
      Parameters:
      strPrefix - The prefix
    • getDataByPrefix

      public static ReferenceList getDataByPrefix(String strPrefix)
      Gets a list of key/value where keys are matching a given prefix
      Parameters:
      strPrefix - The prefix
      Returns:
      The list
    • getInstanceDataByPrefix

      public static ReferenceList getInstanceDataByPrefix(String strPrefix)
      Gets a list of key/value where keys are matching a given prefix depending the current web app instance
      Parameters:
      strPrefix - The prefix
      Returns:
      The list
    • replaceKeys

      public static String replaceKeys(String strSource)
      This method replace keys by their value into a given content
      Parameters:
      strSource - The string that contains datastore keys
      Returns:
      The string with keys replaced
    • existsKey

      public static boolean existsKey(String strKey)
      Check if a key is available in the datastore
      Parameters:
      strKey - The key
      Returns:
      True if the key is found otherwise false
    • existsInstanceKey

      public static boolean existsInstanceKey(String strKey)
      Check if a key is available in the datastore depending the current web app instance
      Parameters:
      strKey - The key
      Returns:
      True if the key is found otherwise false
    • startCache

      public static void startCache()
      Start cache. NB : Cache can't be created at DataStore creation because CacheService uses DatastoreService (Circular reference)