base on Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs. <img src="https://avatars2.githubusercontent.com/u/25752188?v=4" width="50" height="50"> Lettuce - Advanced Java Redis client =============================== [![Integration](https://github.com/redis/lettuce/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/redis/lettuce/actions/workflows/integration.yml) [![codecov](https://codecov.io/gh/redis/lettuce/branch/main/graph/badge.svg?token=pAstxAAjYo)](https://codecov.io/gh/redis/lettuce) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt) [![Maven Central](https://img.shields.io/maven-central/v/io.lettuce/lettuce-core?versionSuffix=RELEASE&logo=redis )](https://maven-badges.herokuapp.com/maven-central/io.lettuce/lettuce-core) [![Javadocs](https://www.javadoc.io/badge/io.lettuce/lettuce-core.svg)](https://www.javadoc.io/doc/io.lettuce/lettuce-core) [![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/redis) [![Twitch](https://img.shields.io/twitch/status/redisinc?style=social)](https://www.twitch.tv/redisinc) [![YouTube](https://img.shields.io/youtube/channel/views/UCD78lHSwYqMlyetR0_P4Vig?style=social)](https://www.youtube.com/redisinc) [![Twitter](https://img.shields.io/twitter/follow/redisinc?style=social)](https://twitter.com/redisinc) [![Stack Exchange questions](https://img.shields.io/stackexchange/stackoverflow/t/lettuce?style=social&logo=stackoverflow&label=Stackoverflow)](https://stackoverflow.com/questions/tagged/lettuce) Lettuce is a scalable thread-safe Redis client for synchronous, asynchronous and reactive usage. Multiple threads may share one connection if they avoid blocking and transactional operations such as `BLPOP` and `MULTI`/`EXEC`. Lettuce is built with [netty](https://github.com/netty/netty). Supports advanced Redis features such as Sentinel, Cluster, Pipelining, Auto-Reconnect and Redis data models. This version of Lettuce has been tested against the latest Redis source-build. * [synchronous](https://redis.github.io/lettuce/user-guide/connecting-redis/#basic-usage), [asynchronous](https://redis.github.io/lettuce/user-guide/async-api/) and [reactive](https://redis.github.io/lettuce/user-guide/reactive-api/) usage * [Redis Sentinel](https://redis.github.io/lettuce/ha-sharding/#redis-sentinel_1) * [Redis Cluster](https://redis.github.io/lettuce/ha-sharding/#redis-cluster) * [SSL](https://redis.github.io/lettuce/advanced-usage/#ssl-connections) and [Unix Domain Socket](https://redis.github.io/lettuce/advanced-usage/#unix-domain-sockets) connections * [Streaming API](https://redis.github.io/lettuce/advanced-usage/#streaming-api) * [Codecs](https://redis.github.io/lettuce/integration-extension/#codecss) (for UTF8/bit/JSON etc. representation of your data) * multiple [Command Interfaces](https://github.com/redis/lettuce/wiki/Command-Interfaces-%284.0%29) * Support for [Native Transports](https://redis.github.io/lettuce/advanced-usage/#native-transports) * Support [RediSearch](https://redis.github.io/lettuce/user-guide/redis-search/), [RedisJSON](https://redis.github.io/lettuce/user-guide/redis-json/) and [Redis Vector Sets](https://redis.github.io/lettuce/user-guide/vector-sets/) * Compatible with Java 8++ (implicit automatic module w/o descriptors) See the [reference documentation](https://redis.github.io/lettuce/) and [API Reference](https://www.javadoc.io/doc/io.lettuce/lettuce-core/latest/index.html) for more details. ## How do I Redis? [Learn for free at Redis University](https://university.redis.io/academy) [Try the Redis Cloud](https://redis.io/try-free/) [Dive in developer tutorials](https://redis.io/learn/) [Join the Redis community](https://redis.io/community/) [Work at Redis](https://redis.io/careers/jobs/) Documentation --------------- * [Reference documentation](https://redis.github.io/lettuce/) * [Javadoc](https://www.javadoc.io/doc/io.lettuce/lettuce-core/latest/index.html) Binaries/Download ---------------- Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org. Releases of lettuce are available in the Maven Central repository. Take also a look at the [Releases](https://github.com/redis/lettuce/releases). Example for Maven: ```xml <dependency> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> <version>x.y.z</version> </dependency> ``` If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version. ```xml <dependency> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> <version>x.y.z.BUILD-SNAPSHOT</version> </dependency> <repositories> <repository> <id>sonatype-snapshots</id> <name>Sonatype Snapshot Repository</name> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> ``` Basic Usage ----------- ```java RedisClient client = RedisClient.create("redis://localhost"); StatefulRedisConnection<String, String> connection = client.connect(); RedisStringCommands sync = connection.sync(); String value = sync.get("key"); ``` Each Redis command is implemented by one or more methods with names identical to the lowercase Redis command name. Complex commands with multiple modifiers that change the result type include the CamelCased modifier as part of the command name, e.g. zrangebyscore and zrangebyscoreWithScores. See [Basic usage](https://redis.github.io/lettuce/user-guide/connecting-redis/#basic-usage) for further details. Asynchronous API ------------------------ ```java StatefulRedisConnection<String, String> connection = client.connect(); RedisStringAsyncCommands<String, String> async = connection.async(); RedisFuture<String> set = async.set("key", "value"); RedisFuture<String> get = async.get("key"); LettuceFutures.awaitAll(set, get) == true set.get() == "OK" get.get() == "value" ``` See [Asynchronous API](https://redis.github.io/lettuce/user-guide/async-api/) for further details. Reactive API ------------------------ ```java StatefulRedisConnection<String, String> connection = client.connect(); RedisStringReactiveCommands<String, String> reactive = connection.reactive(); Mono<String> set = reactive.set("key", "value"); Mono<String> get = reactive.get("key"); set.subscribe(); get.block() == "value" ``` See [Reactive API](https://redis.github.io/lettuce/user-guide/reactive-api/) for further details. Pub/Sub ------- ```java RedisPubSubCommands<String, String> connection = client.connectPubSub().sync(); connection.getStatefulConnection().addListener(new RedisPubSubListener<String, String>() { ... }) connection.subscribe("channel"); ``` Building ----------- Lettuce is built with Apache Maven. The tests require multiple running Redis instances for different test cases which are configured using a ```Makefile```. Tests run by default against Redis `latest`. To build: ``` $ git clone https://github.com/redis/lettuce.git $ cd lettuce/ $ make start ``` * Run the build: ```make test``` * Start Redis (manually): ```make start``` * Stop Redis (manually): ```make stop``` * Clean up: ```make clean``` Bugs and Feedback ----------- For bugs, questions and discussions please use the [GitHub Issues](https://github.com/redis/lettuce/issues). License ------- * This repository is licensed under the "MIT" license. See [LICENSE](LICENSE). * Fork of https://github.com/wg/lettuce Contributing ------- Github is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create Github tickets for bugs and new features and comment on the ones that you are interested in and take a look into [CONTRIBUTING.md](https://github.com/redis/lettuce/blob/main/.github/CONTRIBUTING.md) ", Assign "at most 3 tags" to the expected json: {"id":"9385","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"