Create a special storr that uses separate storage drivers for the keys (which tend to be numerous and small in size) and the data (which tends to be somewhat less numerous and much larger in size). This might be useful to use storage models with different characteristics (in memory/on disk, etc).

storr_multistorr(keys, data, default_namespace = "objects")

Arguments

keys

Driver for the keys

data

Driver for the data

default_namespace

Default namespace (see storr).

Details

This is an experimental feature and somewhat subject to change. In particular, the driver may develop the ability to store small data in the same storr as the keys (say, up to 1kb) based on some tunable parameter.

You can attach another storr to either the data or the key storage (see the example), but it will not be able to see keys or data (respectively). If you garbage collect the data half, all the data will be lost!

Examples

# Create a storr that is stores keys in an environment and data in # an rds path <- tempfile() st <- storr::storr_multistorr(driver_environment(), driver_rds(path)) st$set("a", runif(10)) st$get("a")
#> [1] 0.03123033 0.22556253 0.30083081 0.63646561 0.47902455 0.43217126 #> [7] 0.70643384 0.94857658 0.18033877 0.21689988
# The data can be also seen by connecting to the rds store rds <- storr::storr_rds(path) rds$list() # empty
#> character(0)
rds$list_hashes() # here's the data
#> [1] "d94c5a60cf0f06b8f767e4e5a9585e1a"
rds$get_value(rds$list_hashes())
#> [1] 0.03123033 0.22556253 0.30083081 0.63646561 0.47902455 0.43217126 #> [7] 0.70643384 0.94857658 0.18033877 0.21689988
st$destroy()