Here I changed cache_postgres to facilitate new SQL backends, what I have done is:
In the test file I have only added a call to {memoise} to facilitate interactive tests
As many checks and data were moved to private functions to facilitate the inclusion of new SQL backends. MS SQL Server can, for example, be added like so (I will do it and update the documentation if you are OK with this change):
cache_ms_sql <- R6::R6Class(
"cache_ms_sql",
inherit = cache_postgres,
public = list(
#' @description
#' Start a new Microsoft SQL Server cache
#' @param ... Parameters passes do DBI::dbConnect(odbc::odbc(), ...)
#' @param cache_table On `initialize()`, the cache object will create a table
#' to store the cache. Default name is `bankrcache`. Change it if you already
#' have a table named `bankrcache` in your DB.
#' @param algo for `{memoise}` compatibility, the `digest()` algorithm
#' @param compress for `{memoise}` compatibility, should the data be compressed?
#' @return A cache_ms_sql object
initialize = function(...,
cache_table = "bankrcache",
algo = "sha512",
compress = FALSE) {
private$check_dependencies("cache_ms_sql", "odbc")
private$interface <- private$connect(odbc::odbc(), ...)
private$sql_column_data = list(
column_id = list(type = "varchar(max)", type_description = "varchar"),
column_cache = list(type = "varbinary(max)", type_description = "varbinary")
private$cache_table <- cache_table
private$check_table()
private$algo <- algo
private$compress <- compress
}
)
)
Here I changed
cache_postgres
to facilitate new SQL backends, what I have done is:{memoise}
to facilitate interactive tests