Skip to content

has_cache reads results #123

@kdkavanagh

Description

@kdkavanagh

I think this is a new issue with version 2.0.0. The function generated by has_cache attempts to read the actual cache result into memory before returning that the call is indeed cached. This is problematic for large cached dataframes, etc.

> has_cache(getter)
function (date, arg1) 
{
    mc <- match.call()
    encl <- parent.env(environment())
    called_args <- as.list(mc)[-1]
    default_args <- encl$`_default_args`
    default_args <- default_args[setdiff(names(default_args), 
        names(called_args))]
    called_args[encl$`_omit_args`] <- NULL
    args <- c(lapply(called_args, eval, parent.frame()), lapply(default_args, 
        eval, envir = environment()))
    key <- encl$`_hash`(c(encl$`_f_hash`, args, lapply(encl$`_additional`, 
        function(x) eval(x[[2L]], environment(x)))))

    res <- encl$`_cache`$get(key)  # <---- This should probably be removed?
    return(encl$`_cache`$exists(key))

    if (res$visible) {
        res$value
    }
    else {
        invisible(res$value)
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions