Terracotta DB 10.1 | TCStore API Developer Guide | Reference | Concepts | Read and Write Visibility
 
Read and Write Visibility
Read and write visibilities are the two settings that are required to read or write into a Dataset. The Read Visibility setting of a reader defines whether or not it will see the latest changes made by other writers into the Dataset. The Write Visibility setting of a writer defines how soon its own changes are made visible to other readers of the Dataset.
Read visibility
There are two kinds of read visibility:
*Routine read visibility: This provides standard visibility of a write by an other writer based on its write visibility setting.
*Definitive read visibility: This provides immediate visibility of the latest write by writers regardless of their write visibility setting.
Write visibility
There are two kinds of write visibility:
*Eventual write visibility: Visibility of these writes are eventual or immediate depending on the reader read visibility setting.
*Immediate write visibility: Visibility of these writes are immediate to all the readers, regardless of their reader settings.
Setting up read and write visibility

DatasetReader<Integer> routineReader =
dataset.reader(ROUTINE.asReadSettings()); // <1>
DatasetReader<Integer> definitiveReader =
dataset.reader(DEFINITIVE.asReadSettings()); // <2>
1
Dataset.reader() returns a DatasetReader that is used to read from the dataset. This method takes in ReadSettings as a parameter.
2
Every DatasetReader has a read visibility set for all the reads it performs. This read visibility setting is part of the ReadSettings passed into Dataset.reader() as parameter.

DatasetWriterReader<Integer> writerReader1 =
dataset.writerReader(DEFINITIVE.asReadSettings(), EVENTUAL.asWriteSettings()); // <1>
DatasetWriterReader<Integer> writerReader2 =
dataset.writerReader(DEFINITIVE.asReadSettings(), IMMEDIATE.asWriteSettings()); // <2>
1
Dataset.writerReader() returns a DatasetWriterReader that is used to read and write into the dataset. This method takes in ReadSettings and WriteSettings as parameters.
2
Every DatasetWriterReader has a read and write visibility set for all the reads and writes it performs. The read and write visibility are part of the ReadSettings and WriteSettings passed into Dataset.writerReader() as parameters.
Choosing a read and write visibility
The following table illustrates the behavior of the various pairs of read and write consistency settings.
ROUTINE read visibility
DEFINITIVE read visibility
EVENTUAL write visibility
eventual
immediate
IMMEDIATE write visibility
best perf immediate
avoid (immediate)
If only eventual visibility is required then writes should be EVENTUAL, and reads should be ROUTINE. If only immediate visibility is required then writes should be IMMEDIATE and reads should be ROUTINE. For mixed consistency it is possible to use EVENTUAL for writes and let readers choose the consistency: ROUTINE for eventual, DEFINITIVE for immediate.

Copyright © 2010-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release