Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dengliming/redis-modules-java
Java client libraries for redis-modules https://redis.io/modules, based on Redisson. https://github.com/redisson/redisson
https://github.com/dengliming/redis-modules-java
java-client redis redis-ai redis-client redis-modules redis-search redisai redisbloom redisgears redisgraph redisjson redisson redistimeseries timeseries
Last synced: 3 days ago
JSON representation
Java client libraries for redis-modules https://redis.io/modules, based on Redisson. https://github.com/redisson/redisson
- Host: GitHub
- URL: https://github.com/dengliming/redis-modules-java
- Owner: dengliming
- License: apache-2.0
- Created: 2020-04-10T16:56:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T14:02:40.000Z (2 months ago)
- Last Synced: 2024-12-14T06:06:14.082Z (10 days ago)
- Topics: java-client, redis, redis-ai, redis-client, redis-modules, redis-search, redisai, redisbloom, redisgears, redisgraph, redisjson, redisson, redistimeseries, timeseries
- Language: Java
- Homepage:
- Size: 27.2 MB
- Stars: 83
- Watchers: 8
- Forks: 26
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![build](https://github.com/dengliming/redis-modules-java/workflows/build/badge.svg) ![java-version](https://img.shields.io/badge/JDK-1.8+-brightgreen.svg) [![Maven Central](https://img.shields.io/maven-central/v/io.github.dengliming.redismodule/redis-modules-java.svg?label=maven-central)](https://central.sonatype.com/artifact/io.github.dengliming.redismodule/redis-modules-java) [![license](https://img.shields.io/github/license/dengliming/redis-modules-java)](/LICENSE) [![codecov](https://codecov.io/gh/dengliming/redis-modules-java/branch/master/graph/badge.svg?token=U8BA091JD5)](https://codecov.io/gh/dengliming/redis-modules-java)
Java Client libraries for [redis-modules](https://redis.io/modules), based on [Redisson](https://github.com/redisson/redisson).
## Support
* [RedisBloom](redisbloom)
* [RediSearch](redisearch)
* [RedisTimeSeries](redistimeseries)
* [RedisAI](redisai)
* [RedisGears](redisgears)
* [RedisJSON](redisjson)
* [RedisGraph](redisgraph)## TODO
* [RediSQL](https://redisql.com/)
* [...](https://redis.io/modules)
## Installing#### Build from source
Execute `./mvnw clean install -DskipTests=true -Dgpg.skip`. The build process requires `JDK8+`.#### Maven repository
Include all
```xmlio.github.dengliming.redismodule
all
2.0.4```
Include single module like:
```xmlio.github.dengliming.redismodule
redistimeseries
2.0.4```
## Usage example
RedisBloom
```java
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedisBloomClient redisBloomClient = new RedisBloomClient(config);BloomFilter bloomFilter = redisBloomClient.getRBloomFilter("bf");
bloomFilter.create(0.1d, 100);
bloomFilter.madd(new String[] {"a", "b", "c"});TopKFilter topKFilter = redisBloomClient.getTopKFilter("topk_add");
topKFilter.reserve(1, 2000, 7, 0.925d);
topKFilter.add("test");
List itemExits = topKFilter.query("test");
Map itemIncrement = new HashMap<>();
itemIncrement.put("test", 3);
topKFilter.incrby(itemIncrement);
List allItems = topKFilter.list();CountMinSketch countMinSketch = redisBloomClient.getCountMinSketch("cms_add");
countMinSketch.create(10, 10);
CountMinSketchInfo countMinSketchInfo = countMinSketch.getInfo();CuckooFilter cuckooFilter = redisBloomClient.getCuckooFilter("cf_insert");
List result = cuckooFilter.insert(-1L, false, "a");redisBloomClient.shutdown();
```RediSearch
```java
Config config = new Config();
config.useSingleServer().setAddress("redis://" + DEFAULT_HOST + ":" + DEFAULT_PORT);
RediSearchClient rediSearchClient = new RediSearchClient(config);RediSearch rediSearch = rediSearchClient.getRediSearch("testSearch");
rediSearch.createIndex(new Schema()
.addField(new TextField("title"))
.addField(new TextField("content"))
.addField(new Field("age", FieldType.NUMERIC))
.addField(new Field("location", FieldType.GEO)));Map fields = new HashMap<>();
fields.put("title", "Hi");
fields.put("content", "OOOO");
rediSearch.addDocument(new Document(String.format("doc1"), 1.0d, fields), new DocumentOptions());// Search with NumericFilter
SearchResult searchResult = rediSearch.search("number", new SearchOptions()
.noStopwords()
.language(RSLanguage.ENGLISH)
.filter(new NumericFilter("age", 1, 4)));// Search with GeoFilter
searchResult = rediSearch.search("number", new SearchOptions()
.noStopwords()
.language(RSLanguage.ENGLISH)
.filter(new GeoFilter("location", 15, 37, 200, GeoFilter.Unit.KILOMETERS)));
```RedisTimeSeries
```java
Config config = new Config();
config.useSingleServer().setAddress("redis://192.168.50.16:6383");
RedisTimeSeriesClient redisTimeSeriesClient = new RedisTimeSeriesClient(config);RedisTimeSeries redisTimeSeries = redisTimeSeriesClient.getRedisTimeSeries();
long timestamp = System.currentTimeMillis();
redisTimeSeries.add(new Sample("temperature:2:32", Sample.Value.of(timestamp, 26)), new TimeSeriesOptions()
.retentionTime(6000L)
.unCompressed()
.labels(new Label("sensor_id", "2"), new Label("area_id", "32")));
redisTimeSeriesClient.shutdown();
```RedisAI
```java
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedisAIClient redisAIClient = new RedisAIClient(config);RedisAI redisAI = redisAIClient.getRedisAI();
redisAI.setTensor("tensor1", DataType.FLOAT, new int[]{2, 2}, null, new String[]{"1", "2", "3", "4"});
redisAIClient.shutdown();
```RedisGears
```java
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedisGearsClient redisGearsClient = new RedisGearsClient(config);RedisGears redisGears = redisGearsClient.getRedisGears();
redisGears.pyExecute("GB().run()", false);
redisGearsClient.shutdown();
```RedisJSON
```java
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedisJSONClient redisJSONClient = new RedisJSONClient(config);RedisJSON redisJSON = redisJSONClient.getRedisJSON();
String key = "foo";
Map m = new HashMap<>();
m.put("id", 1);
m.put("name", "lisi");
redisJSON.set(key, SetArgs.Builder.create(".", GsonUtils.toJson(m)));
Map actual = redisJSON.get(key, Map.class, new GetArgs().path(".").indent("\t").newLine("\n").space(" "));
redisJSONClient.shutdown();
```SpringBoot Starter
see [spring-boot-starter](./spring-boot-starter)
## License
[Apache License 2.0](/LICENSE)