Package io.roastedroot.proxywasm
Class SharedData
- java.lang.Object
-
- io.roastedroot.proxywasm.SharedData
-
public class SharedData extends Object
Represents a unit of shared data retrieved from the host environment viaSharedDataHandler.getSharedData(String)
.This class encapsulates the data itself (as a byte array) and its associated Compare-And-Swap (CAS) value. The CAS value acts as a version identifier, enabling optimistic concurrency control when updating shared data using
SharedDataHandler.setSharedData(String, byte[], int)
.
-
-
Constructor Summary
Constructors Constructor Description SharedData(byte[] data, int cas)
Constructs a new SharedData instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
cas()
Gets the Compare-And-Swap (CAS) value associated with this data.byte[]
data()
Gets the raw data bytes.
-
-
-
Constructor Detail
-
SharedData
public SharedData(byte[] data, int cas)
Constructs a new SharedData instance.- Parameters:
data
- The raw byte data retrieved from the shared data store. This might benull
if the key was found but had no associated value, depending on theSharedDataHandler
implementation.cas
- The Compare-And-Swap (version) value associated with this data. A value of 0 typically indicates the key did not exist or CAS is not supported/applicable.
-
-
Method Detail
-
data
public byte[] data()
Gets the raw data bytes.- Returns:
- The byte array representing the shared data's value.
May be
null
.
-
cas
public int cas()
Gets the Compare-And-Swap (CAS) value associated with this data. This value should be passed back toSharedDataHandler.setSharedData(String, byte[], int)
when performing a conditional update.- Returns:
- The integer CAS value.
-
-