Scylla Documentation Logo Documentation
  • Server
    • Scylla Open Source
    • Scylla Enterprise
    • Scylla Alternator
  • Cloud
    • Scylla Cloud
    • Scylla Cloud Docs
  • Tools
    • Scylla Manager
    • Scylla Monitoring Stack
    • Scylla Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
Download
Menu
Scylla C/C++ Driver Documentation Features Basics Client-side timestamps

Client-side timestamps¶

Note: Cassandra 2.1+ is required.

Cassandra uses timestamps to serialize write operations. That is, values with a more current timestamp are considered to be the most up-to-date version of that information. By default, timestamps are assigned by the driver on the client-side. This behavior can be overridden by configuring the driver to use a timestamp generator or assigning a timestamp directly to a CassStatement or CassBatch.

Monotonically Increasing Timestamp Generator¶

The monotonic timestamp generator guarantees that all writes that share this generator will be given monotonically increasing timestamps. This generator produces microsecond timestamps with the sub-millisecond part generated using an atomic counter. That guarantees that no more than 1000 timestamps will be generated for a given millisecond clock tick even when shared by multiple sessions.

Warning: If the rate of 1000 timestamps per millisecond is exceeded this generator will produce duplicate timestamps.

CassCluster* cluster = cass_cluster_new();

CassTimestampGen* timestamp_gen = cass_timestamp_gen_monotonic_new();

cass_cluster_set_timestamp_gen(cluster, timestamp_gen);

/* ... */

/* Connect sessions */

/* Timestamp generators must be freed */
cass_timestamp_gen_free(timestamp_gen);

cass_cluster_free(cluster);

All sessions that connect using this cluster object will share this same timestamp generator.

Per Statement/Batch timestamps¶

Timestamps can also be assigned to individuals CassStatement or CassBatch requests.

CassStatement* statement = cass_statement_new("INSERT INTO * ...", 2);

/* Add a timestamp to the statement */
cass_statement_set_timestamp(statement, 123456789);
CassBatch* batch = cass_batch_new(CASS_BATCH_TYPE_LOGGED);

/* Add a timestamp to the batch */
cass_batch_set_timestamp(batch, 123456789);

/* Add statments to batch */
PREVIOUS
Binding Parameters
NEXT
Consistency
  • C/C++ Driver for ScyllaDB
  • API Documentation
    • CassAggregateMeta
    • CassAuthenticator
    • CassBatch
    • CassCluster
    • CassCollection
    • CassColumnMeta
    • CassCustomPayload
    • CassDataType
    • CassErrorResult
    • CassExecProfile
    • CassFunctionMeta
    • CassFuture
    • CassIndexMeta
    • CassInet
    • CassIterator
    • CassKeyspaceMeta
    • CassMaterializedViewMeta
    • CassMetrics
    • CassNode
    • CassPrepared
    • CassResult
    • CassRetryPolicy
    • CassRow
    • CassSchemaMeta
    • CassSession
    • CassSsl
    • CassStatement
    • CassTableMeta
    • CassTimestampGen
    • CassTuple
    • CassUserType
    • CassUuid
    • CassUuidGen
    • CassValue
    • CassVersion
    • DseDateRange
    • DseDateRangeBound
    • DseLineString
    • DseLineStringIterator
    • DsePolygon
    • DsePolygonIterator
  • Features
    • Basics
      • Batches
      • Binding Parameters
      • Client-side timestamps
      • Consistency
      • Data Types
      • The date and time Types
      • Futures
      • Handling Results
      • Keyspaces
      • Prepared Statements
      • Schema Metadata
      • Tuples
      • User-Defined Types (UDTs)
      • UUIDs
    • Building
    • Client Configuration
    • Cloud
    • Configuration
      • Retry policies
    • Execution Profiles
    • FAQ
    • Installation
    • Logging
    • Metrics
    • Scylla Specific Features
    • Security
      • SSL
    • Testing
      • Cassandra Cluster Manager (CCM)
    • Tracing
  • DSE Features
    • Authentication
    • Geospatial types
  • Create an issue
  • Edit this page

On this page

  • Client-side timestamps
    • Monotonically Increasing Timestamp Generator
    • Per Statement/Batch timestamps
Logo
Docs Contact Us About Us
Mail List Icon Slack Icon
© 2022, ScyllaDB. All rights reserved.
Last updated on 20 May 2022.
Powered by Sphinx 4.3.2 & ScyllaDB Theme 1.2.2