diff --git a/db/c.cc b/db/c.cc index 0dfdbda96..5890d722f 100644 --- a/db/c.cc +++ b/db/c.cc @@ -32,6 +32,7 @@ #include "rocksdb/universal_compaction.h" #include "rocksdb/utilities/backupable_db.h" #include "rocksdb/utilities/checkpoint.h" +#include "rocksdb/utilities/db_ttl.h" #include "rocksdb/utilities/optimistic_transaction_db.h" #include "rocksdb/utilities/transaction.h" #include "rocksdb/utilities/transaction_db.h" @@ -477,6 +478,20 @@ rocksdb_t* rocksdb_open( return result; } +rocksdb_t* rocksdb_open_with_ttl( + const rocksdb_options_t* options, + const char* name, + int ttl, + char** errptr) { + rocksdb::DBWithTTL* db; + if (SaveError(errptr, rocksdb::DBWithTTL::Open(options->rep, std::string(name), &db, ttl))) { + return nullptr; + } + rocksdb_t* result = new rocksdb_t; + result->rep = db; + return result; +} + rocksdb_t* rocksdb_open_for_read_only( const rocksdb_options_t* options, const char* name, diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index d5b739ccc..429188651 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -129,6 +129,9 @@ typedef struct rocksdb_checkpoint_t rocksdb_checkpoint_t; extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open( const rocksdb_options_t* options, const char* name, char** errptr); +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_with_ttl( + const rocksdb_options_t* options, const char* name, int ttl, char** errptr); + extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_for_read_only( const rocksdb_options_t* options, const char* name, unsigned char error_if_log_file_exist, char** errptr);