Skip to content
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

Make memory lru gc the default #12692

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Firestore/Swift/Tests/Integration/DatabaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import FirebaseFirestore

try await db.document("coll/doc").setData(["foo": "bar"])
let result = try? await db.document("coll/doc").getDocument(source: .cache)
XCTAssertNil(result)
XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String])
}

func testCanStillUseEnablePersistenceSettings() async throws {
Expand All @@ -50,7 +50,7 @@ import FirebaseFirestore

try await db.document("coll/doc").setData(["foo": "bar"])
let result = try? await db.document("coll/doc").getDocument(source: .cache)
XCTAssertNil(result)
XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String])
}

func testCanGetDocumentWithMemoryLruGCEnabled() async throws {
Expand Down Expand Up @@ -97,7 +97,7 @@ import FirebaseFirestore

try await db.document("coll/doc").setData(["foo": "bar"])
let result = try? await db.document("coll/doc").getDocument(source: .cache)
XCTAssertNil(result)
XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String])
}

func testGetValidPersistentCacheIndexManager() async throws {
Expand Down
2 changes: 1 addition & 1 deletion Firestore/core/src/api/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ bool Settings::gc_enabled() const {
}
}

return persistence_enabled_ && cache_size_bytes_ != CacheSizeUnlimited;
return cache_size_bytes_ != CacheSizeUnlimited;
}

const LocalCacheSettings* Settings::local_cache_settings() const {
Expand Down
6 changes: 3 additions & 3 deletions Firestore/core/src/api/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class LocalCacheSettings {
friend class Settings;

public:
enum class Kind { kMemory, kPersistent };
enum class Kind { kMemory = 1, kPersistent };
virtual ~LocalCacheSettings() = default;
friend bool operator==(const LocalCacheSettings& lhs,
const LocalCacheSettings& rhs);
Expand Down Expand Up @@ -135,7 +135,7 @@ class PersistentCacheSettings : public LocalCacheSettings {

class MemoryGargabeCollectorSettings {
public:
enum class MemoryGcKind { kEagerGc, kLruGc };
enum class MemoryGcKind { kEagerGc = 1, kLruGc };
virtual ~MemoryGargabeCollectorSettings() = default;
friend bool operator==(const MemoryGargabeCollectorSettings& lhs,
const MemoryGargabeCollectorSettings& rhs);
Expand Down Expand Up @@ -185,7 +185,7 @@ class MemoryCacheSettings : public LocalCacheSettings {
public:
MemoryCacheSettings()
: LocalCacheSettings(LocalCacheSettings::Kind::kMemory),
settings_(absl::make_unique<MemoryEagerGcSettings>()) {
settings_(absl::make_unique<MemoryLruGcSettings>()) {
}
MemoryCacheSettings(const MemoryCacheSettings& other);
MemoryCacheSettings& operator=(const MemoryCacheSettings& other);
Expand Down