redisJson官网地址:RedisJSON Tutorial | Redis Developer Hub
RedisJSON 使 RediSearch 能够索引 JSON 文档,因此用户现在可以通过索引和查询内容来查找文档。这些组合模块为您提供了一个强大的、低延迟的、面向 JSON 的文档数据库!
先决条件:#
- Redis 6.x 或更高版本
- RediSearch 2.2 或更高版本
- RediJSON 2.0 或更高版本
RedisJson发布官方性能报告,性能碾压ES和Mongo:
RedisJSON: Public Preview & Performance Benchmarking | Redis
JRedisJSON是RedisJSON: Public Preview & Performance Benchmarking | Redis的 Java 客户端库:
该客户端提供对 RedisJSON 的 Redis API 的访问,并提供 Java 及其对象之间的来回序列化。该客户端目前支持核心 RedisJSON 命令。
import redis.clients.jedis.Jedis;
import com.redislabs.modules.rejson.JReJSON;
// First get a connection
JReJSON client = new JReJSON("localhost", 6379);
// Setting a Redis key name _foo_ to the string _"bar"_, and reading it back
client.set("foo", "bar");
String s0 = (String) client.get("foo");
// Omitting the path (usually) defaults to the root path, so the call above to
// `get()` and the following ones // are basically interchangeable
String s1 = (String) client.get("foo", new Path("."));
String s2 = (String) client.get("foo", Path.ROOT_PATH);
// Any Gson-able object can be set and updated
client.set("obj", new Object()); // just an empty object
client.set("obj", null, new Path(".zilch"));
Path p = new Path(".whatevs");
client.set("obj", true, p);
client.set("obj", 42, p);
client.del("obj", p); // back to almost nothing