Description Arguments Details Value Examples
reeack connection client
host |
(character) A base URL (without the transport), e.g.,
|
port |
(numeric) Port. Remember that if you don't want a port set,
set this parameter to |
path |
(character) context path that is appended to the end of the
url. e.g., |
transport |
(character) http or https. Default: http |
user |
(character) A user name |
pwd |
(character) A password |
headers |
headers, a named list |
Methods
ping()
Ping the Riak server
stats()
Get Riak server stats
keys()
Get keys
buckets()
Get buckets
bucket_set()
Set bucket properties
bucket_get()
Get bucket properties
create()
Create an object
fetch()
Fetch an object
delete()
Delete an object
An object of class riak_client
, with variables accessible for
host, port, path, transport, user, pwd, and headers. Functions are callable
to get headers, and to make the base url sent with all requests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ## Not run:
# Create a Riak client
(x <- riak())
## metadata
x$host
x$path
x$port
## ping the Riak server
x$ping()
## stats
x$stats()
## keys
### list keys
x$keys()
### in a specific bucket
x$keys("test")
## buckets
### list buckets
x$buckets()
## bucket properties
### set
x$bucket_set("test", n_val = 3, verbose=TRUE)
### get
props <- x$bucket_get("test")
props$props$n_val
## create ~ store
### plain text
x$create(body = "foo bar", content_type = "text/plain")
### json
x$create(body = '{"foo": "bar"}', content_type = "application/json")
### a data.frame
x$create(body = riak_serialize(iris), content_type = "text/plain")
#### with a key
x$create(key = "doc", body = "foo bar", content_type = "text/plain")
## fetch from store
### plain text
res <- x$create(body = "foo bar", content_type = "text/plain")
x$fetch(key = res$key)
### json
res <- x$create(body = '{"foo": "bar"}', content_type = "application/json")
jsonlite::fromJSON(x$fetch(key = res$key))
### a data.frame
res <- x$create(body = riak_serialize(iris), content_type = "text/plain")
head(
riak_unserialize(x$fetch(key = res$key))
)
## delete from store
(res <- x$keys("test")$keys)
x$delete(key = res[1])
res[1] %in% x$keys("test")$keys
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.