infinispan-rs is a Rust client for the Infinispan REST API. For now, it implements a small part of the API.
Add the infinispan
dependency to your Cargo.toml
:
toml
[dependencies]
infinispan = "0.2"
```rust use infinispan::Infinispan; use infinispan::request;
// Create a client let client = Infinispan::new("http://localhost:11222", "username", "password");
// Create a cache let req = request::caches::createlocal("somecache"); let _ = client.run(&req).await.unwrap();
// Create an entry let req = request::entries::create("somecache", "someentry").withvalue("avalue".into()); let _ = client.run(&req).await.unwrap();
// Read the entry let req = request::entries::get("somecache", "someentry"); let resp = client.run(&req).await.unwrap();
// resp is an instance of reqwest::Response
assert!(resp.status().issuccess());
asserteq!("avalue", resp.textwith_charset("utf-8").await.unwrap());
```
Check the docs to learn more.
bash
cargo build
Some tests need Infinispan running in localhost:11222
. You can run it in
Docker with:
bash
docker run -it -p 11222:11222 -e USER="username" -e PASS="password" infinispan/server:11.0.9.Final
Then, run the tests:
bash
cargo test