Class DatastoreService
java.lang.Object
fr.paris.lutece.portal.service.datastore.DatastoreService
Datastore Service
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Lutece107Cache<String,DataEntity> static final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic voidevictCachedKey(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.static booleanexistsInstanceKey(String strKey) Check if a key is available in the datastore depending the current web app instancestatic booleanCheck if a key is available in the datastorestatic ReferenceListgetDataByPrefix(String strPrefix) Gets a list of key/value where keys are matching a given prefixstatic StringgetDataValue(String strKey, String strDefault) Get entitystatic ReferenceListgetInstanceDataByPrefix(String strPrefix) Gets a list of key/value where keys are matching a given prefix depending the current web app instancestatic StringgetInstanceDataValue(String strKey, String strDefault) Get entity depending the current web app instancestatic voidinit()initialize the servicestatic booleaninsertDataValueIfAbsent(String strKey, String strValue) Atomically sets a value only if the key does not already exist in the datastore.static booleanisTemplateKey(String strKey) Tells whether a datastore key can be read from a template, by the#dskey{key}marker or thedskey( key )method.static voidremoveData(String strKey) Remove a give keystatic voidremoveDataByPrefix(String strPrefix) Remove all data where keys begin with a given prefixstatic voidremoveInstanceData(String strKey) Remove a give key depending the current web app instancestatic voidremoveInstanceDataByPrefix(String strPrefix) Remove all data where keys begin with a given prefix depending the current web app instancestatic StringreplaceKeys(String strSource) This method replace keys by their value into a given contentstatic voidsetDataValue(String strKey, String strValue) Set entitystatic voidsetInstanceDataValue(String strKey, String strValue) Set entity depending the current web app instancestatic voidStart cache.
-
Field Details
-
VALUE_TRUE
- See Also:
-
VALUE_FALSE
- See Also:
-
_cache
-
-
Method Details
-
evictCachedKey
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
Get entity- Parameters:
strKey- The entity's keystrDefault- The default value- Returns:
- The value
-
getInstanceDataValue
Get entity depending the current web app instance- Parameters:
strKey- The entity's keystrDefault- The default value- Returns:
- The value
-
setDataValue
Set entity- Parameters:
strKey- The entity's keystrValue- The value
-
setInstanceDataValue
Set entity depending the current web app instance- Parameters:
strKey- The entity's keystrValue- The value
-
insertDataValueIfAbsent
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 ofcore_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 keystrValue- The value to insert if the key is absent- Returns:
trueif the value was stored,falseif the key already existed (in which case the stored value is left untouched)- Since:
- 8.0
-
removeData
Remove a give key- Parameters:
strKey- The key
-
removeInstanceData
Remove a give key depending the current web app instance- Parameters:
strKey- The key
-
removeDataByPrefix
Remove all data where keys begin with a given prefix- Parameters:
strPrefix- The prefix
-
removeInstanceDataByPrefix
Remove all data where keys begin with a given prefix depending the current web app instance- Parameters:
strPrefix- The prefix
-
getDataByPrefix
Gets a list of key/value where keys are matching a given prefix- Parameters:
strPrefix- The prefix- Returns:
- The list
-
getInstanceDataByPrefix
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
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
-
isTemplateKey
Tells whether a datastore key can be read from a template, by the#dskey{key}marker or thedskey( key )method. Templates read the site properties (keys containing.site_property.) and the keys starting with a prefix of the core or of the propertydatastore.template.allowedKeyPrefixes(comma separated).- Parameters:
strKey- the key- Returns:
- true if a template can read the key
-
existsKey
Check if a key is available in the datastore- Parameters:
strKey- The key- Returns:
- True if the key is found otherwise false
-
existsInstanceKey
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)
-