# ----------------------Basic Usage ----------------------
# Define a path to your map.
path = tempfile()
map <- rds_map(path)
# Reset
map$reset()
# Check if the map is corrupted.
map$validate()
# You have not set any key-value pairs yet.
# Let's say two parallel processes (A and B) are sharing this map.
# Process A set values
map$keys()
# Start push
# set a normal message
map$set(key = 'a', value = 1)
# set a large object
map$set(key = 'b', value = rnorm(100000))
# set an object with hash of another object
map$set(key = 'c', value = 2, signature = list(
parameter1 = 123,
parameter2 = 124
))
# Check what's in the map from process B
mapB <- rds_map(path)
mapB$keys()
mapB$keys(include_signatures = TRUE)
# Number of key-values pairs in the map.
mapB$size()
# Check if key exists
mapB$has(c('1','a', 'c'))
# Check if key exists and signature also matches
mapB$has('c', signature = list(
parameter1 = 123,
parameter2 = 124
))
# Signature changed, then return FALSE. This is especially useful when
# value is really large and reading the value takes tons of time
mapB$has('c', signature = list(
parameter1 = 1244444,
parameter2 = 124
))
# Destroy the map's files altogether.
mapB$destroy()
if (FALSE) {
# Once destroyed, validate will raise error
mapB$validate()
}
Run the code above in your browser using DataLab