From f021f1d9e14d9915457885c3fcee4ab86775dc7b Mon Sep 17 00:00:00 2001 From: Stuart Date: Tue, 6 Mar 2018 20:51:30 -0800 Subject: [PATCH] Add rocksdb_open_with_ttl function in C API Summary: Change-Id: Ie6f9b10bce459f6bf0ade0e5877264b4e10da3f5 Signed-off-by: Stuart Closes https://github.com/facebook/rocksdb/pull/3553 Differential Revision: D7144833 Pulled By: sagar0 fbshipit-source-id: 815225fa6e560d8a5bc47ffd0a98118b107ce264 --- db/c.cc | 15 +++++++++++++++ include/rocksdb/c.h | 3 +++ 2 files changed, 18 insertions(+) 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);