redis.get: Get/set/query database content

Description Usage Arguments Details Note Author(s) See Also

View source: R/redis.R

Description

redis.get retrieves values for given keys

redis.set sets (stores/replaces) values for given keys

redis.rm removes values for given keys

redis.keys lists all keys matching a pattern

Usage

1
2
3
4
redis.get(rc, keys, list = FALSE, character = FALSE)
redis.set(rc, keys, values, as.is = FALSE)
redis.rm (rc, keys)
redis.keys(rc, pattern = NULL)

Arguments

rc

redis connection handle as returned by redis.connect

keys

character vector of keys. For redis.set this can also be a named list in which case the names are used as keys and elements as values.

list

logical, if FALSE then keys is expected to be a single key and the return will be the value. If TRUE then the result is always a list with one value for each key.

character

logical, if TRUE then values are expected to be character vectors (not serialized). If FALSE the results are raw vectors and unserialized.

values

only used if keys is a character vector. If keys is a single string then the content of values will be stored under that key. Otherwise it must be a list of the same length as keys and each element will be stored under the corresponding key.

as.is

logical, if TRUE the character vectors are stored directly without serialization. Otherwise objects are first serialized before storing.

pattern

string with a glob-style pattern as suppored by Redis or NULL to retrieve all keys

Details

redis.get retrieves values associated with the speicifed keys. If list is FALSE then keys is expected to be a single string and the value is returned directly. If list is TRUE then a list is returned with one result element for each key element. If a key doesn't exist NULL is returned for that key. If character is TRUE then the result is a (named) character vector with as many entries as there are keys. If any of the results are not strings, a warning is issued and NA value is returned for any such element.

redis.set sets one or more key/value pairs. If keys is of length one then values is interpreted directly as a single value. If keys is a character vector of length of more than one, then values must be a list of the same length. Finally, keys can be a named list in which case values are ignored and names of the list are taken as keys and elements as values.

redis.rm removes a key/value pair from the database. See the note below for the difference of redis.rm and setting a value of NULL.

redis.keys list all matching keys present in the database.

Note

rediscc was originally written as a replacement of rredis so it shares the serialized value format which has a few odd implications. rredis doesn't store values directly, but uses R serialization to store the serialized content in the value. On the plus side it means that arbitrary values can be stored, but it also means that storing an integer into a key will result in the storage of a binary blob such that seemingly intuitive actions like incrementing it don't work since Redis doesn't recognize it as a number. Also it means that it is possible to store the value NULL in the key but this is not distinguishable from the deleted key since redis.get will return NULL in both cases.

Author(s)

Simon Urbanek

See Also

redis.connect


s-u/rediscc documentation built on July 22, 2020, 2:18 a.m.