| rcppredis_connection | R Documentation |
Support for using RcppRedis with RedisAPI.
rcppredis_connection(config = redis_config()) rcppredis_hiredis(..., version = NULL) rcppredis_available(...)
config |
A named list of configuration options, as generated
by |
... |
arguments passed through to |
version |
Version of the RedisAPI to generate. If given as a
numeric version (or something that can be coerced into one. If
given as |
Note that via this interface RcppRedis will not support binary
serialisation (even though it does through its own interface) so
you need to use object_to_string/string_to_object
rather than object_to_bin/bin_to_object.
Treatment of TRUE/FALSE is different as redux will store them as
1/0 but RcppRedis will store as "TRUE"/"FALSE". Both will be
converted back to TRUE/FALSE after as.logical though.
RcppRedis returns strings for Redis statuses (which are
just strings) but redux/rrlite add a redis_status
attribute. You'll see this most obviously with the printing of
OK following a successful SET.
The rcppredis_available function is a simple test that can
be used to detect if RcppRedis is available on a system. It will
return TRUE if RcppRedis is installed, and if passing
... through to rcppredis_hiredis can create a Redis
connection. This will fail if the Redis database cannot be
reached, or if the Redis server requires authentication (which is
not handled in this interface).
if (rcppredis_available()) {
# This is the main entry point to use:
con <- rcppredis_hiredis()
# The returned object has many methods:
con
# Because RedisAPI provides the full API you can avoid using
# functions like "KEYS" (which can block the Redis server)
# con$KEYS("*")
# and instead use SCAN:
con$SCAN(0, "*")
# This pattern is formalised by the "scan_find" function (see
# ?scan_find).
scan_find(con, "*")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.