Description Usage Arguments Details Value See Also Examples
This functions return an object embedding Redis connection parameters. It can be propagated across all workers to share the same connect to the same redis database.
1 | redis_client(type = NULL, ...)
|
type |
type of client, see details |
... |
parameters to transmit to the client implementation (host, port, ...) |
RedisClient:
Returns an instance of RedisClient
class with methods allowing to manipulate 'Redis' database using a unified interface
As this package only needs a subset of 'Redis' commands are implemented. It's a very simple implementation to avoid extra dependency, limited to this package needs.
The returned "client" embeds connection configuration and can be propagated in distributed workers (like with 'foreach' package). So the client connection parameters are only to be defined once.
Clients:
rredis package, discontinued
for RcppRedis
for redux and rrlite
Mock type, in memory R-only client
The returned instance exposes the following functions :
connect to redis db
get key value
get field value in HashSet
named by key
set field value in HashSet
named by key
set field value for a counter in HashSet named by key
Increment a field by the amount provided in by
. Caution the field must have been initialized by hashSetCounter
not by hashSet
remove the key key value
returns TRUE the key exists
add a value on the tail of the list named by key
returns all fields in the HashSet named by key. If not implemented client will not be usable for monitoring
Accepted parameters are
name of host
get key value
Redis database number
Some other parameters, not yet normalized across interfaces
instance of a RedisClient class (described in details section)
Other backend:
RedisClientMock-class
,
RedisClientRRedis-class
,
RedisClientRcpp-class
,
RedisClientRedux-class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Create a simple client using rredis as backend
client = redis_client(host="127.0.0.1", type="rredis")
# Using another backend and database number 2
client = redis_client(host="127.0.0.1", type="redux", database=2)
## Not run:
client$connect() # Initiate connection
## End(Not run)
client = redis_client("mock") # Mock client (in-memory only client)
client$connect()
client$exists("my-key") # Test if 'my-key' exists
client$set("my-key", 12) # Set a value
client$get("my-key")
client$hashSetCounter("a-key", "counter", 1) # Set a counter value in a hash field
client$hashIncrBy("a-key", "counter", 1) # Increment by 1
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.