@ParametersAreNonnullByDefault public class CachingOfBizPropertyEntryStore extends Object implements OfBizPropertyEntryStore
Concurrency note: To minimize data inconsistency, mutative operations are (mostly) transactional. To prevent deadlocks, modifications are made to the entry first, then the value. Modifications to entries use the row count to determine whether they were successful or should be counted as overwritten. That is, any time we expect to update or delete a row, we include the type in the request. If the row does not match, then we abort that attempt.
OfBizPropertyEntryStore.PropertyEntry
Constructor and Description |
---|
CachingOfBizPropertyEntryStore(QueryDslAccessor queryDslAccessor,
com.atlassian.cache.CacheManager cacheManager) |
Modifier and Type | Method and Description |
---|---|
protected com.atlassian.jira.propertyset.CachingOfBizPropertyEntryStore.Operation |
createRemoveOperation(String entityName,
long entityId,
String propertyKey) |
protected com.atlassian.jira.propertyset.CachingOfBizPropertyEntryStore.Operation |
createSetOperation(String entityName,
long entityId,
String propertyKey,
int type,
Object value) |
boolean |
exists(String entityName,
long entityId,
String propertyKey)
Queries whether or not the specified property exists
|
OfBizPropertyEntryStore.PropertyEntry |
getEntry(String entityName,
long entityId,
String propertyKey)
Retrieve the type and value of the specified property.
|
Collection<String> |
getKeys(String entityName,
long entityId)
Retrieve all keys that are stored in the given property set.
|
Collection<String> |
getKeys(String entityName,
long entityId,
int type)
Retrieve all keys that are stored in the given property set and have the specified value type.
|
int |
getType(String entityName,
long entityId,
String propertyKey)
Queries the type of the specified property, if it exists.
|
void |
invalidateCacheEntry(String entityName,
long entityId) |
void |
onClearCache(ClearCacheEvent event) |
void |
onDatabaseImportCompleted(DatabaseImportCompletedEvent event) |
void |
refreshAll() |
void |
removeEntry(String entityName,
long entityId,
String propertyKey)
Remove a specific property from a property set.
|
void |
removePropertySet(String entityName,
long entityId)
Removes an entire property set.
|
void |
setEntry(String entityName,
long entityId,
String propertyKey,
int type,
Object value)
Stores a new value for the specified property.
|
public CachingOfBizPropertyEntryStore(QueryDslAccessor queryDslAccessor, com.atlassian.cache.CacheManager cacheManager)
@Nonnull public Collection<String> getKeys(String entityName, long entityId)
OfBizPropertyEntryStore
getKeys
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's owner@Nonnull public Collection<String> getKeys(String entityName, long entityId, int type)
OfBizPropertyEntryStore
getKeys
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownertype
- the value type, as defined by the value constants in the PropertySet
interface,
that the keys must have to be returnedpublic OfBizPropertyEntryStore.PropertyEntry getEntry(String entityName, long entityId, String propertyKey)
OfBizPropertyEntryStore
getEntry
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownerpropertyKey
- the name of the property to loadnull
if the property does not exist. Note that even if it does "exist",
the value
can itself be null
.public boolean exists(String entityName, long entityId, String propertyKey)
OfBizPropertyEntryStore
exists
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownerpropertyKey
- the name of the property to checkpublic int getType(String entityName, long entityId, String propertyKey)
OfBizPropertyEntryStore
getType
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownerpropertyKey
- the name of the property for which to retrieve the type0
if the property does not existpublic void setEntry(String entityName, long entityId, String propertyKey, int type, Object value)
OfBizPropertyEntryStore
setEntry
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownerpropertyKey
- the name of the property to storetype
- the value type that is to be stored, as defined by the value constants in the
PropertySet
interface.value
- the value to be stored. WARNINGSpecifying null
may be tolerated
for specific types, but it is generally not supported and can possibly have inconsistent
results. Use OfBizPropertyEntryStore.removeEntry(String, long, String)
, instead.public void removeEntry(String entityName, long entityId, String propertyKey)
OfBizPropertyEntryStore
removeEntry
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownerpropertyKey
- the name of the property to removeprotected com.atlassian.jira.propertyset.CachingOfBizPropertyEntryStore.Operation createRemoveOperation(String entityName, long entityId, String propertyKey)
protected com.atlassian.jira.propertyset.CachingOfBizPropertyEntryStore.Operation createSetOperation(String entityName, long entityId, String propertyKey, int type, Object value)
public void removePropertySet(String entityName, long entityId)
Implementation note: There is a concurrency race here if removal of the entire property set overlaps with someone else adding a new value to it or changing the type of an existing property. The worst case result is that the new value entry would get orphaned. Removing an entire property set is pretty rare, doing so concurrently with adding a new value to it should be rare squared, and as consequences go this one is pretty tolerable. As a result, this problem is deliberately ignored. Along those lines, this is not a transactional operation, either. Exceptions during value removal are caught and logged as warnings instead of propagated.
removePropertySet
in interface OfBizPropertyEntryStore
entityName
- the entity name of the property set's ownerentityId
- the entity ID of the property set's ownerpublic void invalidateCacheEntry(String entityName, long entityId)
public void refreshAll()
@EventListener public void onClearCache(@Nullable ClearCacheEvent event)
@EventListener public void onDatabaseImportCompleted(DatabaseImportCompletedEvent event)
Copyright © 2002-2022 Atlassian. All Rights Reserved.