Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead required by traditional caching solutions. This repo contains the source code for the Momento client library for Java.
To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.
- Website: https://www.gomomento.com/
- Momento Documentation: https://docs.momentohq.com/
- Getting Started: https://docs.momentohq.com/getting-started
- Momento SDK Documentation for Java: https://docs.momentohq.com/sdks/java
- Discuss: Momento Discord
The Java SDK is available on Maven Central:
implementation("software.momento.java:sdk:1.0.0")
<dependency>
<groupId>software.momento.java</groupId>
<artifactId>sdk</artifactId>
<version>1.0.0</version>
</dependency>
package momento.client.example.doc_examples;
import java.time.Duration;
import momento.sdk.CacheClient;
import momento.sdk.auth.CredentialProvider;
import momento.sdk.config.Configurations;
import momento.sdk.responses.cache.GetResponse;
public class ReadmeExample {
public static void main(String[] args) {
try (final CacheClient cacheClient =
CacheClient.create(
CredentialProvider.fromEnvVar("MOMENTO_API_KEY"),
Configurations.Laptop.v1(),
Duration.ofSeconds(60))) {
final String cacheName = "cache";
cacheClient.createCache(cacheName).join();
cacheClient.set(cacheName, "foo", "bar").join();
final GetResponse response = cacheClient.get(cacheName, "foo").join();
if (response instanceof GetResponse.Hit hit) {
System.out.println("Got value: " + hit.valueString());
}
}
}
}
Documentation is available on the Momento Docs website.
Working example projects, with all required build configuration files, are available in the examples subdirectory.
If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.
For more info, visit our website at https://gomomento.com!