Origin does that, so should we. Both ttl and expiry time are stored in sstables. The value of ttl seems to be used to calculate the read digest (expiry is not used for that). The API for creating atomic_cells changed a bit. To create a non-expiring cell: atomic_cell::make_live(timestamp, value); To create an expiring cell: atomic_cell::make_live(timestamp, value, expiry, ttl); or: // Expiry is calculated based on current clock reading atomic_cell::make_live(timestamp, value, ttl_optional);
30 lines
796 B
C++
30 lines
796 B
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <experimental/optional>
|
|
|
|
// FIXME: wraps around in 2038
|
|
class gc_clock {
|
|
public:
|
|
using base = std::chrono::system_clock;
|
|
using rep = int32_t;
|
|
using period = std::ratio<1, 1>; // seconds
|
|
using duration = std::chrono::duration<rep, period>;
|
|
using time_point = std::chrono::time_point<gc_clock, duration>;
|
|
|
|
static time_point now() {
|
|
return time_point(std::chrono::duration_cast<duration>(base::now().time_since_epoch()));
|
|
}
|
|
};
|
|
|
|
|
|
using expiry_opt = std::experimental::optional<gc_clock::time_point>;
|
|
using ttl_opt = std::experimental::optional<gc_clock::duration>;
|
|
|
|
// 20 years in seconds
|
|
static constexpr gc_clock::duration max_ttl = gc_clock::duration{20 * 365 * 24 * 60 * 60};
|