Skip to content

In clear(), remove keys in bulk instead of one by one.  #121

@wlandau

Description

@wlandau

clear() removes keys one by one, which is slower than it could be for RDS storrs.

storr/R/storr.R

Line 207 in 0c64f1e

invisible(length(vlapply(self$list(namespace), self$del, namespace)))

library(storr)
init_storr <- function() {
  s <- storr_rds(tempfile())
  keys <- as.character(seq_len(1e4))
  values <- rep(TRUE, length(keys))
  s$mset(keys, values)
  s
}

s <- init_storr()
system.time(s$clear())
#>    user  system elapsed 
#>   0.244   0.866   1.111

s <- init_storr()
system.time(unlink(file.path(s$path, "keys", s$default_namespace), recursive = TRUE))
#>    user  system elapsed 
#>       0       0       0

Created on 2020-03-11 by the reprex package (v0.3.0)

@richfitz, would you be open to driver-specific clear() methods so we can do whatever is fastest for the situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions