Skip to content

Commit

Permalink
single function to set memoisation options
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed Feb 10, 2024
1 parent d942db1 commit 6426243
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(filter_properties)
export(forget_gemma_memoised)
export(gemma_call)
export(gemma_kable)
export(gemma_memoise)
export(get_all_pages)
export(get_child_terms)
export(get_dataset_annotations)
Expand Down
16 changes: 11 additions & 5 deletions R/aa_caching.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ in_memory_cache <- function(...){

#' Enable and disable memoisation of gemma.R functions
#' @param memoised boolean. If TRUE memoisation will be enabled
#' @return Option set for memoisation
#' @keywords internal
gemma_memoise <- function(memoised = NULL){
options('gemma.memoised' = setting)
getOption('gemma.memoised',FALSE)
#' @param cache File path or "cache_in_memory". File path will chose a location
#' to save the cache files for memoisation. "cache_in_memory" will store the cache
#' in the current R session
#' @return NULL
#' @keywords misc
#' @export
gemma_memoise <- function(memoised = FALSE,
cache = rappdirs::user_cache_dir(appname ='gemmaR')){
options('gemma.memoised' = memoised)
options('gemma.cache' = cache)
NULL
}

mem_in_memory_cache <- memoise::memoise(in_memory_cache, cache = memoise::cache_memory())
2 changes: 1 addition & 1 deletion R/gemma.R.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ utils::globalVariables(c("platform.ID", "analysis.ID", "analysis.Threshold", "ba
"subsetFactor.categoryURI", "subsetFactor.Enabled", "subsetFactor.factorValue",
"subsetFactor.factorValueURI", "valueUri", "category",
"categoryURI", "experimental.factorValue","value",
"contrast.ID","%$%",'baseline.factors','setting'))
"contrast.ID","%$%",'baseline.factors'))
14 changes: 9 additions & 5 deletions man/gemma_memoise.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6426243

Please sign in to comment.