-
Notifications
You must be signed in to change notification settings - Fork 39
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
Remove scope and collection cache #512
Conversation
* Removed scope and collection cache in the CBLDatabase implementation. This change made CBL-C inline with the other platforms’ implementation. Plus, it makes the implementation much more simpler. * CBLDatabase still caches the (internal) default collection used for default collection based APIs (Most are the deprecated APIs). Once we remove those deprecated API, we may not need to have it. * When caching the internal default collection in the CBLDatabase, to prevent the retain cycle, call CBLCollection’s adopt(db) function to release the database instance in the CBLCollection object. * The database instance inside CBLCollection and CBLScope will not be invalidated. This makes several part of the code that needs the database instance much simplier as it doesn’t need to take care the case when the database is null. * Made changes to the tests as needed. Plus, fix XCode analyzer warning in QueryTest.cc about setting nullptr to listenerToken. * Fixed wrong information about default collection in CBLCollection. (We will need to fix this in 3.1 branch as well). * Updated LiteCore to 3.2.0-115 otherwise it’s not buildable on XCode 15. Need to fix LogTest as now the log files have two header lines.
Code Coverage Results:
|
src/CBLDatabase.cc
Outdated
} | ||
return collection; | ||
Retained<CBLCollection> CBLDatabase::createCBLCollection(C4Collection* c4col, CBLScope* scope) { | ||
return new CBLCollection(c4col, scope, const_cast<CBLDatabase*>(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to have this instead of the every call of createCBLCollection
for both getCollection
and createCollection
, similar to Scope implementation, having returning new
. Would that be a bit more readable?
It won't make much of a difference... I might just be picky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can be done.
As database in collection will not be invalidated anymore, we don’t need to explicitly retaining the database in a couple of places.
Removed scope and collection cache in the CBLDatabase implementation. This change made CBL-C inline with the other platforms’ implementation. Plus, it makes the implementation much more simpler.
CBLDatabase still caches the (internal) default collection used for default collection based APIs (Most are the deprecated APIs). Once we remove those deprecated API, we may not need to have it.
When caching the internal default collection in the CBLDatabase, to prevent the retain cycle, call CBLCollection’s adopt(db) function to release the database instance in the CBLCollection object.
The database instance inside CBLCollection and CBLScope will not be invalidated. This makes several part of the code that needs the database instance much simplier as it doesn’t need to take care the case when the database is null.
Made changes to the tests as needed. Plus, fix XCode analyzer warning in QueryTest.cc about setting nullptr to listenerToken.
Fixed wrong information about default collection in CBLCollection. (We will need to fix this in 3.1 branch as well).
Updated LiteCore to 3.2.0-115 otherwise it’s not buildable on XCode 15. Need to fix LogTest as now the log files have two header lines.