Wednesday, 12 February 2020

CQL: default_time_to_live: Setting default expiration time to the data at table creation time

'default_time_to_live' is used to set the default expiration time (“TTL”) in seconds for a table.

Example
CREATE TABLE IF NOT EXISTS cassandratutorial.employee (
  id INT PRIMARY KEY,
  firstName VARCHAR,
  lastName VARCHAR,
  age int,
) WITH default_time_to_live=3600;

cqlsh> CREATE TABLE IF NOT EXISTS cassandratutorial.employee (
   ...   id INT PRIMARY KEY, 
   ...   firstName VARCHAR,
   ...   lastName VARCHAR,
   ...   age int,
   ... ) WITH default_time_to_live=3600;
cqlsh> 
cqlsh> DESCRIBE cassandratutorial.employee;

CREATE TABLE cassandratutorial.employee (
    id int PRIMARY KEY,
    age int,
    firstname text,
    lastname text
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 3600
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

cqlsh>


Previous                                                    Next                                                    Home

No comments:

Post a Comment