Skip to content

Commit

Permalink
fix: Implement ResetAllDB for LevelDbCache
Browse files Browse the repository at this point in the history
- Add ResetAllDB virtual method implementation
- Fix abstract class instantiation error
- Maintain consistency with Redis implementation
  • Loading branch information
devin-ai-integration[bot] authored and ohhmm committed Feb 13, 2025
1 parent 476faef commit 9137c74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion omnn/storage/LevelDbCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>


using namespace omnn::rt::storage;
using namespace omnn::rt::storage;


LevelDbCache::LevelDbCache(const std::string_view& path)
Expand Down Expand Up @@ -36,6 +36,20 @@ bool LevelDbCache::Clear(const std::string_view &key) {
return _status.ok();
}

bool LevelDbCache::ResetAllDB(const path_str_t& path) {

Check failure on line 39 in omnn/storage/LevelDbCache.cpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

‘using omnn::rt::storage::CacheBase::path_str_t = class boost::filesystem::path’ is private within this context

Check failure on line 39 in omnn/storage/LevelDbCache.cpp

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'path_str_t' is a private member of 'omnn::rt::storage::CacheBase'

Check failure on line 39 in omnn/storage/LevelDbCache.cpp

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'omnn::rt::storage::CacheBase::path_str_t': cannot access private typedef declared in class 'omnn::rt::storage::CacheBase'
// Delete all keys in the database
auto it = _db->NewIterator(leveldb::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next()) {
auto status = _db->Delete(leveldb::WriteOptions(), it->key());
if (!status.ok()) {
delete it;
return false;
}
}
delete it;
return true;
}

LevelDbCache::~LevelDbCache() {
delete _db;
}
Expand Down
1 change: 1 addition & 0 deletions omnn/storage/LevelDbCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class LevelDbCache
std::string GetOne(const std::string_view& key) override;
bool Set(const std::string_view& key, const std::string_view& v) override;
bool Clear(const std::string_view& key) override;
bool ResetAllDB(const path_str_t& path) override;

Check failure on line 23 in omnn/storage/LevelDbCache.h

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

‘using omnn::rt::storage::CacheBase::path_str_t = class boost::filesystem::path’ is private within this context

Check failure on line 23 in omnn/storage/LevelDbCache.h

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

‘using omnn::rt::storage::CacheBase::path_str_t = class boost::filesystem::path’ is private within this context

Check failure on line 23 in omnn/storage/LevelDbCache.h

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'path_str_t' is a private member of 'omnn::rt::storage::CacheBase'

Check failure on line 23 in omnn/storage/LevelDbCache.h

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'path_str_t' is a private member of 'omnn::rt::storage::CacheBase'

Check failure on line 23 in omnn/storage/LevelDbCache.h

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'omnn::rt::storage::CacheBase::path_str_t': cannot access private typedef declared in class 'omnn::rt::storage::CacheBase'

Check failure on line 23 in omnn/storage/LevelDbCache.h

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'omnn::rt::storage::CacheBase::path_str_t': cannot access private typedef declared in class 'omnn::rt::storage::CacheBase'
~LevelDbCache() override;

static const leveldb::Options& GetDbConnectionOptions();
Expand Down

0 comments on commit 9137c74

Please sign in to comment.