Simple java app
In your preferred IDE create a simple maven java project.
pom.xml​
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>rostore101</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<artifactId>rostore-client</artifactId>
<groupId>net.ro-store</groupId>
<version>2.0.1</version>
</dependency>
</dependencies>
</project>
Main.java​
package org.example;
import org.rostore.client.*;
import org.rostore.client.mapper.StringMapper;
import java.util.UUID;
public class Main {
/** Public connection on server ro-store.net storage.
* It grants access to the container named "test".
* This container is restricted to hold up to 50MB of data.
* Maximum lifespan of entries in this container is 3600s or 1 hour, any entry will be removed after this period of time.
*/
private static final RoStoreClientProperties ROSTORE_CONNECTION = new RoStoreClientProperties("https://ro-store.net", "7d23b7d6-f10a-40f1-9cdf-555b77c1dee6");
public static void main(String[] args) {
// create a client
final RoStoreClient ro = new RoStoreClient(ROSTORE_CONNECTION);
// create a container "test" instance
final MappedContainer<String> testContainer = ro.getMappedContainer("test", new StringMapper());
// create a random key
final String key = UUID.randomUUID().toString();
// create a value (override it if you like)
final String value = "test-value";
// create a key-value versioned object (version is not used) that is not restricted in life-span
// The lifespan will be overwritten to be 1h as per container policy
VersionedObject<String, String> obj = VersionedObject.createUnversionedEternal(key, value);
// post the object to the server
testContainer.post(obj);
// read the object from the server
VersionedObject<String, String> readObject = testContainer.get(key, String.class);
// printout the value from the server
System.out.println("Object value: " + readObject.getValue());
}
}