-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
700 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,119 @@ | ||
# momento-java-lettuce-client | ||
Momento-backed implementation of [@lettuce](https://github.com/redis/lettuce) client | ||
<img src="https://docs.momentohq.com/img/momento-logo-forest.svg" alt="logo" width="400"/> | ||
|
||
[![project status](https://momentohq.github.io/standards-and-practices/badges/project-status-official.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md) | ||
[![project stability](https://momentohq.github.io/standards-and-practices/badges/project-stability-alpha.svg)](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md) | ||
|
||
|
||
# Momento Lettuce Compatibility Client | ||
|
||
## What and why? | ||
|
||
This project provides a Momento-backed implementation of [lettuce](https://github.com/redis/lettuce) | ||
The goal is to provide a drop-in replacement for [lettuce](https://github.com/redis/lettuce) so that you can | ||
use the same code with either a Redis server or with the Momento Cache service! | ||
|
||
## Installation | ||
|
||
To use the compatiblity client, you will need three dependencies in your project: the Momento Lettuce compatibility client, the Momento Cache client, and the lettuce client. | ||
|
||
The Momento Lettuce compatibility client is [available on Maven Central](https://search.maven.org/artifact/software.momento.java/momento-lettuce). You can add it to your project via: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>software.momento.java</groupId> | ||
<artifactId>momento-lettuce</artifactId> | ||
<version>0.1.0</version> | ||
</dependency> | ||
``` | ||
|
||
You will also need to add the Momento Cache client library to your project. You can find the latest version of the Momento Cache client library [on Maven Central](https://central.sonatype.com/artifact/software.momento.java/sdk) as well: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>software.momento.java</groupId> | ||
<artifactId>sdk</artifactId> | ||
<version>1.15.0</version> | ||
</dependency> | ||
``` | ||
|
||
As well as the lettuce client also [on Maven Central](https://central.sonatype.com/artifact/io.lettuce/lettuce-core). | ||
|
||
## Usage | ||
|
||
To switch your existing `lettuce` application to use Momento Cache, you only need to change the code where you construct your client object. Here is an example of constructing a Momento lettuce client: | ||
|
||
```java | ||
package momento.lettuce.example.doc_examples; | ||
|
||
import io.lettuce.core.api.reactive.RedisReactiveCommands; | ||
import java.time.Duration; | ||
import momento.lettuce.MomentoRedisReactiveClient; | ||
import momento.sdk.CacheClient; | ||
import momento.sdk.auth.CredentialProvider; | ||
import momento.sdk.config.Configurations; | ||
|
||
class ReadmeExample { | ||
public static void main(String[] args) { | ||
// Create a Momento cache client | ||
try (final CacheClient cacheClient = | ||
CacheClient.create( | ||
CredentialProvider.fromEnvVar("MOMENTO_API_KEY"), | ||
Configurations.Laptop.v1(), | ||
Duration.ofSeconds(60))) { | ||
final String cacheName = "cache"; | ||
|
||
// Create a Redis client backed by the Momento cache client over the cache | ||
RedisReactiveCommands<String, String> redisClient = | ||
MomentoRedisReactiveClient.create(cacheClient, cacheName); | ||
|
||
// Perform operations vs Momento as if using a regular Redis client | ||
var setResult = redisClient.set("key", "value").block(); | ||
System.out.println("Set result: " + setResult); | ||
|
||
var getResult = redisClient.get("key").block(); | ||
System.out.println("Get result: " + getResult); | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
Additionally, to understand what APIs are supported, you can use the interface `MomentoRedisReactiveCommands` which contains only those APIs that are supported by this compatibility client: | ||
|
||
```java | ||
package momento.lettuce.example.doc_examples; | ||
|
||
import java.time.Duration; | ||
import momento.lettuce.MomentoRedisReactiveClient; | ||
import momento.lettuce.MomentoRedisReactiveCommands; | ||
import momento.sdk.CacheClient; | ||
import momento.sdk.auth.CredentialProvider; | ||
import momento.sdk.config.Configurations; | ||
|
||
class LimitedApiExample { | ||
public static void main(String[] args) { | ||
// Create a Momento cache client | ||
try (final CacheClient cacheClient = | ||
CacheClient.create( | ||
CredentialProvider.fromEnvVar("MOMENTO_API_KEY"), | ||
Configurations.Laptop.v1(), | ||
Duration.ofSeconds(60))) { | ||
final String cacheName = "cache"; | ||
|
||
// This interface provides type safety as it only allows the user to interact with the | ||
// RedisReactiveCommands | ||
// commands that are supported by the MomentoRedisReactiveCommands class | ||
MomentoRedisReactiveCommands<String, String> redisClient = | ||
MomentoRedisReactiveClient.create(cacheClient, cacheName); | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
## Current Redis API support | ||
|
||
This library supports the most popular Redis APIs, but does not yet support all Redis APIs. We currently support the most common APIs related to string values (`get`, `set`, `unlink`), as well as list (`lpush`, `lrange`, `ltrim`). We will be adding support for additional APIs in the future. If there is a particular API that you need support for, please drop by our [Discord](https://discord.com/invite/3HkAKjUZGq) or e-mail us at [[email protected]](mailto:[email protected]) and let us know! | ||
|
||
---------------------------------------------------------------------------------------- | ||
For more info, visit our website at [https://gomomento.com](https://gomomento.com)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{{ ossHeader }} | ||
|
||
# Momento Lettuce Compatibility Client | ||
|
||
## What and why? | ||
|
||
This project provides a Momento-backed implementation of [lettuce](https://github.com/redis/lettuce) | ||
The goal is to provide a drop-in replacement for [lettuce](https://github.com/redis/lettuce) so that you can | ||
use the same code with either a Redis server or with the Momento Cache service! | ||
|
||
## Installation | ||
|
||
To use the compatiblity client, you will need three dependencies in your project: the Momento Lettuce compatibility client, the Momento Cache client, and the lettuce client. | ||
|
||
The Momento Lettuce compatibility client is [available on Maven Central](https://search.maven.org/artifact/software.momento.java/momento-lettuce). You can add it to your project via: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>software.momento.java</groupId> | ||
<artifactId>momento-lettuce</artifactId> | ||
<version>0.1.0</version> | ||
</dependency> | ||
``` | ||
|
||
You will also need to add the Momento Cache client library to your project. You can find the latest version of the Momento Cache client library [on Maven Central](https://central.sonatype.com/artifact/software.momento.java/sdk) as well: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>software.momento.java</groupId> | ||
<artifactId>sdk</artifactId> | ||
<version>1.15.0</version> | ||
</dependency> | ||
``` | ||
|
||
As well as the lettuce client also [on Maven Central](https://central.sonatype.com/artifact/io.lettuce/lettuce-core). | ||
|
||
## Usage | ||
|
||
To switch your existing `lettuce` application to use Momento Cache, you only need to change the code where you construct your client object. Here is an example of constructing a Momento lettuce client: | ||
|
||
```java | ||
{% include "./examples/src/main/java/momento/lettuce/example/doc_examples/ReadmeExample.java" %} | ||
``` | ||
|
||
Additionally, to understand what APIs are supported, you can use the interface `MomentoRedisReactiveCommands` which contains only those APIs that are supported by this compatibility client: | ||
|
||
```java | ||
{% include "./examples/src/main/java/momento/lettuce/example/doc_examples/LimitedApiExample.java" %} | ||
``` | ||
|
||
## Current Redis API support | ||
|
||
This library supports the most popular Redis APIs, but does not yet support all Redis APIs. We currently support the most common APIs related to string values (`get`, `set`, `unlink`), as well as list (`lpush`, `lrange`, `ltrim`). We will be adding support for additional APIs in the future. If there is a particular API that you need support for, please drop by our [Discord](https://discord.com/invite/3HkAKjUZGq) or e-mail us at [[email protected]](mailto:[email protected]) and let us know! | ||
|
||
{{ ossFooter }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id("java") | ||
id("com.diffplug.spotless") version "5.15.1" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("io.lettuce:lettuce-core:6.4.0.RELEASE") | ||
implementation("software.momento.java:momento-lettuce:0.1.0") | ||
implementation("software.momento.java:sdk:1.15.0") | ||
} | ||
|
||
spotless { | ||
java { | ||
removeUnusedImports() | ||
googleJavaFormat("1.11.0") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Needed for https://github.com/diffplug/spotless/issues/834 | ||
# Google's Java Fromat has compatibility issues with JDK 16 - | ||
# https://github.com/google/google-java-format#jdk-16 | ||
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ | ||
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ | ||
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \ | ||
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ | ||
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Mon Sep 16 10:36:21 PDT 2024 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.