-
Notifications
You must be signed in to change notification settings - Fork 32
chore (OPTDataStore): Remove print statements and change memory store default backing store. #310
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
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.
Need small changes
|
||
|
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.
remove spaces
set { | ||
|
||
} |
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.
remove
func testPerformanceExample() { | ||
// This is an example of a performance test case. | ||
self.measure { |
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.
remove
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. |
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.
remove
|
||
XCTAssert(v2 == value) |
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.
Let's clean up here test data which may be left from previous test:
UserDefaults.standard.removeObject(forKey: "testUserDefaultsTooBig")
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.
it is never saved because it is too big. :)
Co-Authored-By: Jae Kim <[email protected]>
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.
It looks good functionally. One concern is about if the datafile can fit in UserDefaults, and the overall space taken from UserDefaults together with event queues.
public func removeItem(sdkKey:String) { | ||
if let store = self as? DataStoreUserDefaults { | ||
store.removeItem(sdkKey: sdkKey) | ||
} | ||
else if let store = self as? DataStoreFile<Data> { | ||
store.removeItem(sdkKey: sdkKey) | ||
} | ||
else if let store = self as? DataStoreMemory<Data> { | ||
store.removeItem(sdkKey: sdkKey) |
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.
It must be for backward compatibility. Can't we leave it empty? All our datastores override it. Also we can move it to the end of OPTDataStore for readability.
public func removeItem(sdkKey: String) { }
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.
no because that is the method called on the extension (i.e. the other implementation is not an override since it is an extension). the only alternative is to add it to the data store protocol directly.
} | ||
else { | ||
#if os(tvOS) | ||
let store = DataStoreUserDefaults() |
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.
It looks good, but I'm concerned about the datafile size which can grow big more than MB. They may not fit into UserDefaults max configs in many cases. Also with event queues, it can take substantial spaces in UserDefaults even if they can fit in 128KB each.
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.
even if you reach 512k in tvOS, the action is that the user is notified, it can actually grow beyond that. So, this is probably pretty safe. That said, if the datafile is too big, what choice do they have on tvOS?
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.
basically, the same thing will happen as happens now on tvOS. start async, caching fails, but you can continue. the bigger question may be do we want to disable polling for tvOS? i am really curious why the simulator doesn't fail.
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.
Polling is optional, so we don't need to block it. They won't turn it on if not working.
We can also consider "Cache" folder as done in ObjC. Both methods are not fully reliable for keeping datafile cache and events.
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
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
Summary