diff --git a/db/db_impl.cc b/db/db_impl.cc index f96d245..3d26371 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1198,6 +1198,11 @@ Status DBImpl::Put(const WriteOptions& o, const Slice& key, const Slice& val) { return DB::Put(o, key, val); } +Status DBImpl::Put(const WriteOptions& options, const Slice& key, + const Slice& value, uint64_t ttl) { + return DB::Put(options,key,value,ttl); +} + Status DBImpl::Delete(const WriteOptions& options, const Slice& key) { return DB::Delete(options, key); } @@ -1491,6 +1496,14 @@ Status DB::Put(const WriteOptions& opt, const Slice& key, const Slice& value) { return Write(opt, &batch); } +//为了通过编译,忽略ttl +Status DB::Put(const WriteOptions& options, const Slice& key, + const Slice& value, uint64_t ttl) { + WriteBatch batch; + batch.Put(key, value); + return Write(options, &batch); +} + Status DB::Delete(const WriteOptions& opt, const Slice& key) { WriteBatch batch; batch.Delete(key); diff --git a/db/db_impl.h b/db/db_impl.h index c7b0172..993c63e 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -38,6 +38,8 @@ class DBImpl : public DB { // Implementations of the DB interface Status Put(const WriteOptions&, const Slice& key, const Slice& value) override; + Status Put(const WriteOptions& options, const Slice& key, + const Slice& value, uint64_t ttl) override; Status Delete(const WriteOptions&, const Slice& key) override; Status Write(const WriteOptions& options, WriteBatch* updates) override; Status Get(const ReadOptions& options, const Slice& key, diff --git a/db/db_test.cc b/db/db_test.cc index a4a84cd..7baec2a 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2117,6 +2117,9 @@ class ModelDB : public DB { Status Put(const WriteOptions& o, const Slice& k, const Slice& v) override { return DB::Put(o, k, v); } + Status Put(const WriteOptions& o, const Slice& k,const Slice& v,uint64_t ttl) { + return DB::Put(o,k,v); + } Status Delete(const WriteOptions& o, const Slice& key) override { return DB::Delete(o, key); } diff --git a/port/port.h b/port/port.h index 4b247f7..c2073f3 100644 --- a/port/port.h +++ b/port/port.h @@ -7,6 +7,9 @@ #include +#ifndef LEVELDB_PLATFORM_POSIX + #define LEVELDB_PLATFORM_POSIX +#endif // Include the appropriate platform specific file below. If you are // porting to a new platform, see "port_example.h" for documentation // of what the new port_.h file must provide. diff --git a/test/db_test2.cc b/test/db_test2.cc index 49e26ab..4b2b33c 100644 --- a/test/db_test2.cc +++ b/test/db_test2.cc @@ -68,6 +68,7 @@ int main() { GetData(db); delete db; } + DestroyDB("testdb",Options()); return 0; } diff --git a/test/ttl_test.cc b/test/ttl_test.cc index 06f4cda..0cc64f3 100644 --- a/test/ttl_test.cc +++ b/test/ttl_test.cc @@ -99,9 +99,9 @@ TEST(TestTTL, CompactionTTL) { db->CompactRange(nullptr, nullptr); - leveldb::Range ranges[1]; + // leveldb::Range ranges[1]; ranges[0] = leveldb::Range("-", "A"); - uint64_t sizes[1]; + // uint64_t sizes[1]; db->GetApproximateSizes(ranges, 1, sizes); ASSERT_EQ(sizes[0], 0); }