Interface PutOption


public interface PutOption
The PutOption interface defines a set of options for customizing the behavior of a "put" operation in a data store. These options allow fine-grained control over conditions, partitioning, indexing, and key management associated with the operation.
  • Field Details

    • IfRecordDoesNotExist

      static final PutOption IfRecordDoesNotExist
      Specifies that the operation should only proceed if the record does not already exist. This option is useful for enforcing the creation of a new record exclusively when no existing record is found with the specified key.

      When this option is used, if a record with the provided key already exists, the operation will not proceed. The condition ensures idempotency in create operations.

    • AsEphemeralRecord

      static final PutOption AsEphemeralRecord
      Indicates that the record should be treated as ephemeral. Ephemeral records are scoped to a specific session, and their lifecycle is tied to the session's duration. Once the session expires or is terminated, the ephemeral record will no longer exist.

      This option is typically used when records do not need to persist beyond the lifespan of a client session.

  • Method Details

    • IfVersionIdEquals

      static io.oxia.client.api.options.defs.OptionVersionId.OptionVersionIdEqual IfVersionIdEquals(long versionId)
      Only put the record if the versionId matches the current versionId.
      Parameters:
      versionId - the version ID to be used for the equality condition
      Returns:
      an OptionVersionId.OptionVersionIdEqual instance representing the version ID equality condition
    • PartitionKey

      static PutOption PartitionKey(String partitionKey)
      PartitionKey overrides the partition routing with the specified `partitionKey` instead of the regular record key.

      Records with the same partitionKey will always be guaranteed to be co-located in the same Oxia shard.

      Parameters:
      partitionKey - the partition key to use
      Returns:
      the PutOption.
    • SequenceKeysDeltas

      static PutOption SequenceKeysDeltas(List<Long> sequenceKeysDeltas)
      SequenceKeysDeltas will request that the final record key to be assigned by the server, based on the prefix record key and appending one or more sequences.

      The sequence numbers will be atomically added based on the deltas. Deltas must be >= 0 and the first one strictly > 0. SequenceKeysDeltas also requires that a [PartitionKey] option is provided.

      Parameters:
      sequenceKeysDeltas - a list of sequence numbers to be added to the record key
      Returns:
      the PutOption.
    • SecondaryIndex

      static PutOption SecondaryIndex(String indexName, String secondaryKey)
      SecondaryIndex let the users specify additional keys to index the record Index names are arbitrary strings and can be used in SyncOxiaClient.list(String, String, Set) and SyncOxiaClient.rangeScan(String, String, Set) requests.

      Secondary keys are not required to be unique.

      Multiple secondary indexes can be passed on the same record, even reusing multiple times the same indexName.

      Parameters:
      indexName - the name of the secondary index
      secondaryKey - the secondary key for this record
      Returns:
      the PutOption.