Configure Global Object Expiration
By default, LevelDB keeps all of your data. But Riak TS allows you to configure global object expiration (
expiry) or time to live (TTL) for your data.
Currently only global expiration is supported in Riak TS.
Expiration is disabled by default, but enabling it lets you expire older objects to reclaim the space used or purge data with a limited time value.
To enable global object expiry, add the
leveldb.expiration setting to your riak.conf file:
leveldb.expiration = on
Turning on global object expiration will not retroactively expire previous data. Only data created while expiration is on will be scheduled for expiration.
Setting Retention Time
retention_time setting is used to specify the time until objects expire.
Durations are set using a combination of an integer and a shortcut for the supported units:
- Milliseconds -
- Seconds -
- Minutes -
- Hours -
- Days -
- Weeks -
- Fortnight -
The following example configures objects to expire after 5 hours:
leveldb.expiration = on leveldb.expiration.retention_time = 5h
You can also combine durations. For example, let’s say you wanted objects to expire after 8 days and 9 hours:
leveldb.expiration = on leveldb.expiration.retention_time = 8d9h
Global expiration supports two modes:
whole_file- the whole sorted string table (
.sst) file is deleted when all of its objects are expired.
normal- individual objects are removed as part of the usual compaction process.
We recommend using
whole_file with time series data that has a similar lifespan, as it will be much more efficient.
The following example configure objects to expire after 1 day:
leveldb.expiration = on leveldb.expiration.retention_time = 1d leveldb.expiration.mode = whole_file
To disable global object expiration, set
off in your riak.conf file. If expiration is disabled, the other 2 settings are ignored. For example:
leveldb.expiration = off leveldb.expiration.retention_time = 1d leveldb.expiration.mode = whole_file