Skip to content

New Cache Config and LRU GC #1308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Using new cache api, for future reference.
  • Loading branch information
wu-hui committed May 9, 2023
commit d65416d6d30add9c3c73ba18ea69ad03169acb51
24 changes: 19 additions & 5 deletions firestore/src/main/firestore_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "firestore/src/main/document_reference_main.h"
#include "firestore/src/main/document_snapshot_main.h"
#include "firestore/src/main/listener_main.h"
#include "firestore/src/main/local_cache_settings_main.h"

namespace firebase {
namespace firestore {
Expand Down Expand Up @@ -190,11 +191,24 @@ Settings FirestoreInternal::settings() const {
const api::Settings& from = firestore_core_->settings();
result.set_host(from.host());
result.set_ssl_enabled(from.ssl_enabled());
result.set_persistence_enabled(from.persistence_enabled());
result.set_cache_size_bytes(from.cache_size_bytes());
// TODO(wuandy): This line should be deleted when legacy cache config is
// removed.
result.used_legacy_cache_settings_ = false;

if(from.local_cache_settings() == nullptr) {
if(from.persistence_enabled()) {
result.set_local_cache_settings(PersistentCacheSettings::Create().WithSizeBytes(from.cache_size_bytes()));
} else {
result.set_local_cache_settings(MemoryCacheSettings::Create());
}
}
else if (from.local_cache_settings()->kind() ==
api::LocalCacheSettings::Kind::kMemory) {
result.set_local_cache_settings(MemoryCacheSettings::CreateFromCoreSettings(
dynamic_cast<const CoreMemorySettings&>(*from.local_cache_settings())));
} else {
result.set_local_cache_settings(
PersistentCacheSettings::CreateFromCoreSettings(
dynamic_cast<const CorePersistentSettings&>(
*from.local_cache_settings())));
}

return result;
}
Expand Down