-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: CacheFS #18
feat: CacheFS #18
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.
Good job. Some improvement comments. I would like to see how you are going to compose keys.
prototype.write = function (key as String, data as Object) as Boolean | ||
if (key = "") then return false | ||
|
||
content = FormatJson(data) |
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 add check if content = invalid return false
. Thats because if data
is corrupted FormatJson
will return invalid. Not needed to store invalid (not sure if you can anyway)
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.
In case of an error, FormatJson returns an empty string according to the documentation.
And from what I experienced.
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.
hmm
FormatJson({s:})
Syntax Error. (compile error &h02) in $LIVECOMPILE(126)
invalid
are you sure @bchelkowski?
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.
Is it from the console directly? You shouldn't be able to compile this code.
for example, this should return an empty string:
FormatJson({a: CreateObject("roSGNode", "Node")})
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.
And to be honest I cannot think of a case where you will receive a corrupted data argument.
Without a crash
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.
And to be honest I cannot think of a case where you will receive a corrupted data argument.
Without a crash
From docs:
An error will be returned if arrays/associative arrays are nested more than 256 levels deep.
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.
a,d should be valid only? c "null", f and g "null"? b "asd"
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 added a safety check. Please take a look
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.
answers to the quiz above:
a = "[]"
b = ""asd""
c = "null"
d = "1"
e = "null"
f = ""
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.
@RadoslawZambrowski
The answer is... there is missing an "e" option 😄
Actually, it works as expected for JSON parser.
For more than 256 levels deep object - FromJson still returns an empty string. No invalid, or other error object.
Just prints in the logs that the error occurred.
Fun (or sad) fact: I needed to generate that JSON in JavaScript because BrightScript throws a stack overflow error when I use recurrence more than 177 times. Or maybe there is a limit of 180 backtrace lines.
Co-authored-by: Błażej Chełkowski <bchelkow@gmail.com>
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.
Looks good!
' @param {Object} data - any value acceptable by native FormatJson function except Invalid | ||
' @returns {Boolean} false if data is not parseable or if storing failed | ||
prototype.write = function (key as String, data as Object) as Boolean | ||
if (key = "" OR data = Invalid) then return false |
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'm not sure if you can say that data that is Invalid
, is not parseable.
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'm not saying this - that's why in docs I put any value acceptable by native FormatJson function except Invalid
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.
ok, but in jsdoc you have
' @returns {Boolean} false if data is not parseable or if storing failed
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.
ok, I will add Invalid exception
if (key = "" OR data = Invalid) then return false | ||
|
||
content = FormatJson(data) | ||
if (content = "") then return false |
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.
Pretty much the same as Invalid data
, it is hard to say if data
, in that case, wasn't just an empty string,
so maybe we should return false, only if the content
is an empty string but data
is not.
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's not. If it were an empty string, it would be """"
. It's covered by a unit test
🎉 This PR is included in version 2.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What did you implement:
An abstraction over Roku's native CacheFS caching mechanism
How did you implement it:
CacheFS prototype-based object + Roku's EVPDigest component with mock
How can we verify it:
Run unit tests
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO