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
Postgresql #1
Postgresql #1
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.
Couple of notes on dependencies and a simplification.
High level
- Are you planning to merge this into
r-lib/memoise
? - Is it worth setting up a postgres instance in travis for testing?
Also Keith and I were just talking about this yesterday!
DESCRIPTION
Outdated
@@ -13,12 +13,15 @@ Description: Cache the results of a function so that when you call it | |||
URL: https://github.com/r-lib/memoise | |||
BugReports: https://github.com/r-lib/memoise/issues | |||
Imports: | |||
digest (>= 0.6.3) | |||
digest (>= 0.6.3), |
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 comma probably
R/cache_postgresql.R
Outdated
if (!(requireNamespace("readr"))) { stop("Package `readr` must be installed for `cache_postgresql()`.") } # nocov | ||
|
||
cache_reset <- function() { | ||
dbSendQuery( |
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.
The tests are failing from R packaging, e.g. DBI::dbSendQuery
needs to be added to all the imported functions used
R/cache_postgresql.R
Outdated
temp_file <- file.path(path, key) | ||
on.exit(unlink(temp_file)) | ||
saveRDS(value, file = temp_file, compress = compress, ascii = TRUE) | ||
encoded <- readr::read_file(temp_file) |
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.
Why is the readr
dependency necessary? Would readBin
from base do?
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.
🔥
R/cache_postgresql.R
Outdated
key = key | ||
) | ||
) | ||
readr::write_file(rs[1][[1]], temp_file) |
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 possible to read the file directly from rs
instead of writing to/from temporary files?
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.
My answer is no, I don't think you can serialize without using textConnections, which have memory limits.
R/cache_postgresql.R
Outdated
) | ||
is_here <- nrow(rs) == 1 | ||
# if not result is logical(0) | ||
if(identical(is_here, logical(0))){ |
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 (!is.null(rs) && nrow(rs) == 1) TRUE else FALSE
will do it one line
Codecov Report
@@ Coverage Diff @@
## master #1 +/- ##
=========================================
Coverage ? 68.37%
=========================================
Files ? 6
Lines ? 313
Branches ? 0
=========================================
Hits ? 214
Misses ? 99
Partials ? 0
Continue to review full report at Codecov.
|
Back to you! |
This is as good as I can review! LGTM |
Thanks for looping me in too, I learned a lot! |
No description provided.