public enum CacheSyncStrategy extends java.lang.Enum<CacheSyncStrategy> implements ValueEnum
automatic cache
synchronization
, for a given DataSource
, OperationBinding
or DSRequest
. Enum Constant and Description |
---|
ALWAYSSYNC
Obtain cache sync values by refetching the record we just updated or added, immediately after the update operation.
|
REQUESTVALUESPLUSSEQUENCES
Obtain cache sync values by merging the request values on top of the request's
oldValues . |
RESPONSEVALUES
This strategy simply returns the data returned by the add or update operation, as the cache sync data.
|
SYNCFORCLIENTRESPONSES
This is the same as
alwaysSync for requests that originate from the client; for server-originated requests,
the cache sync operation will be deferred, and will not run at all if it is not needed - ie, if nothing requests the
response data by calling dsResponse.getData() , or one of its type-specific alternatives
(getDataMap() and getDataList() ). |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getValue() |
static CacheSyncStrategy |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static CacheSyncStrategy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final CacheSyncStrategy ALWAYSSYNC
primary key fields
of type
sequence
, the framework will first attempt to obtain values for those fields - see sequenceMode
. This is the most complete and foolproof way to get cache sync
data, because we pick up any changes to the record that were applied by the persistence layer - for example database
default values, values applied by database triggers or transformations applied to the record we sent by a remote REST
service or legacy program call. However, it is also the least performant, since it involves a full refetch of the data.
This is the default strategy for SQL DataSources
, and also for Hibernate
and JPA
DataSources, though for the latter two, it is implemented inherently by the ORM system. See the cache synchronization overview
for details
If this enumerated value is used in a Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "alwaysSync".
public static final CacheSyncStrategy SYNCFORCLIENTRESPONSES
alwaysSync
for requests that originate from the client; for server-originated requests,
the cache sync operation will be deferred, and will not run at all if it is not needed - ie, if nothing requests the
response data by calling dsResponse.getData()
, or one of its type-specific alternatives
(getDataMap()
and getDataList()
). This strategy is only a potential optimization of
alwaysSync
: if the response data is not required, it avoids a possibly expensive refetch operation, but if
the cache sync data is actually required, it offers no performance advantage
If this enumerated value is used in a Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "syncForClientResponses".
public static final CacheSyncStrategy REQUESTVALUESPLUSSEQUENCES
oldValues
. If the DataSource contains primary key fields
of type sequence
, the framework will
then attempt to obtain values for those fields - see sequenceMode
- and
merge those values into the cache sync data as well. Note, if no oldValues
are available and the updated
record is incomplete
, this strategy will return
incomplete cache sync data. It does, however, avoid a data refetch, which may be a significant performance gain.
Despite the name, this strategy is also suitable and effective for situations where your keys are not sequences - for
example, when they are GUIDs or when they are user-entered codes. In this case, we simply do not attempt to resolve
sequence values, and since the key values are already included in the request values, everything works
If this enumerated value is used in a Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "requestValuesPlusSequences".
public static final CacheSyncStrategy RESPONSEVALUES
DataSource
types that return a value for an update operation. This may include generic
DataSources and RESTDataSources
, depending entirely on what the implementation returns. It specifically
does not include SQL DataSources
, because SQL/JDBC update operations do
not return a value (other than the number of affected records). This is the default strategy for RESTDataSources,
partly because it was the default way we did cache sync for that DataSource type before CacheSyncStrategy
was introduced, and partly because a default strategy that involves a second network call to a potentially slow REST
service could be a performance disaster. It is also the default strategy for custom/generic DataSource implmentations
If this enumerated value is used in a Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "responseValues".
public static CacheSyncStrategy[] values()
for (CacheSyncStrategy c : CacheSyncStrategy.values()) System.out.println(c);
public static CacheSyncStrategy valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null