-
Notifications
You must be signed in to change notification settings - Fork 909
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
Implement LRU Reference Delegate for Memory Persistence #1237
Conversation
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.
Some questions/suggestions. Overall, this is a pretty close port to Android, which makes it easy to review. Thanks!
|
||
private _started = false; | ||
|
||
private _referenceDelegate: ReferenceDelegate | null; | ||
get referenceDelegate(): ReferenceDelegate { |
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.
If you do keep this, please move it down past the constructor.
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.
As above, this will eventually just be a property. It's just waiting on the final reference delegate implementation.
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.
I would still like to push you to move this down to where we define other methods.
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.
Done.
|
||
private _started = false; | ||
|
||
private _referenceDelegate: ReferenceDelegate | null; |
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.
We have been using just ReferenceDelegate as a the type if a member is essentially always set. Would it be possible to pass the delegate into the constructor from your factory function? You could then also make the variable itself public and remove the getter.
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.
Can I punt on this until the next PR? That one will introduce MemoryEagerDelegate
, and then there will always be a reference delegate for memory persistence.
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.
Please add a TODO to clean this up then :)
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.
Done.
promises.push(referenceDelegate.addReference(txn, key)); | ||
}); | ||
} | ||
return PersistencePromise.waitFor(promises); |
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.
If the set of keys here is small, you could also do:
return PersistencePromise.forEach(keys.toArray(), key -> referenceDelegate.addReference(txn, key));
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.
I don't know if it's small? It's however many keys are added to a target.
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.
LGTM module a todo and moving the new getter method a little further down.
This PR adds only the lru reference delegate for memory. The merge base is into
lru-master
.Android Port: FirebasePrivate/firebase-android-sdk#190
iOS Port: firebase/firebase-ios-sdk#1600