Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 3.15 KB

README.md

File metadata and controls

89 lines (63 loc) · 3.15 KB

logo

project status project stability

Momento Client Library for Java

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.

Packages

The Java SDK is available on Maven Central:

Gradle

implementation("software.momento.java:sdk:1.0.0")

Maven

<dependency>
    <groupId>software.momento.java</groupId>
    <artifactId>sdk</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

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());
      }
    }
  }
}

Getting Started and Documentation

Documentation is available on the Momento Docs website.

Examples

Working example projects, with all required build configuration files, are available in the examples subdirectory.

Developing

If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.


For more info, visit our website at https://gomomento.com!