Invoking the Infinispan REST Server API from R

The following script demonstrates the R Infinispan API functions for calling an instance of the Infinispan REST Server; the image below shows the output.

In this example the user transforms a data frame into JSON, puts (via DoPut) that JSON into the cache, and then gets this information (via DoGet) as JSON and transforms it back into a data frame.

library ('ropensecretsapi')
library ('RJSONIO')
library ('rinfinispanapi')

ropensecretsapi::SetAPIKey ("redacted")

params <- list (org="Microsoft")
msftDataFrame <- ropensecretsapi::GetOrgsData (params)
msftDataFrame
msftAsJson <- RJSONIO::toJSON (msftDataFrame)

SetEndpointURL ("http://192.168.1.4:8585/infinispan-server-rest/rest")
#
# Expected "Error: Not Found" as the entry does not exist in the cache.
#
DoGet  ("___defaultcache", cacheKey="msft")
DoPut (
    "___defaultcache",
    cacheKey="msft",
    payload=msftAsJson,
    headers=list ("Content-Type"="application/json")
)
newMsftAsJson <- DoGet  ("___defaultcache", cacheKey="msft")
newMsftDataFrame <- RJSONIO::fromJSON (newMsftAsJson)
newMsftDataFrame
DoHead ("___defaultcache", cacheKey="msft")
DoDelete ("___defaultcache", cacheKey="msft")
#
# Expected "Error: Not Found" as the entry has been deleted.
#
DoGet  ("___defaultcache", cacheKey="msft")

An example script that calls the Infinispan REST Server from R