Skip to content

Conversation

@wlandau
Copy link
Contributor

@wlandau wlandau commented Mar 15, 2020

This PR implements the original proposal in #121 (comment).

Changes

  1. The RDS driver now has a clear() method, which uses unlink(recursive = TRUE) instead of deleting keys one by one from R.
  2. The clear() method in the storr base class looks for a driver's clear() method first, then defaults to deleting keys one by one if the driver has no such method.
  3. The return value of clear() in RDS drivers is integer(0) instead of the number of deleted keys.
  4. Tests updated to reflect (3).

Benchmarks

We see the speed improvements we expected from #121 (comment).

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

s <- init_storr()
system.time(s$clear())
#>    user  system elapsed 
#>   0.000   0.000   0.001

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant