在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:redis/jedis开源软件地址:https://github.com/redis/jedis开源编程语言:Java 99.3%开源软件介绍:JedisWhat is Jedis?Jedis is a Java client for Redis designed for performance and ease of use. ContributingWe'd love your contributions! Bug reports are always welcome! You can open a bug report on GitHub. You can also contribute documentation -- or anything to improve Jedis. Please see contribution guideline for more details. Getting startedTo get started with Jedis, first add it as a dependency in your Java project. If you're using Maven, that looks like this: <dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.2.0</version>
</dependency> Next, you'll need to connect to Redis. For many applications, it's best to use a connection pool. You can instantiate a Jedis connection pool like so: JedisPool pool = new JedisPool("localhost", 6379); With a Here's how to run a single SET command within a try-with-resources block: try (Jedis jedis = pool.getResource()) {
jedis.set("clientName", "Jedis");
}
Easier way of using connection poolUsing a try-with-resources block for each command may be cumbursome, so you may consider using JedisPooled. JedisPooled jedis = new JedisPooled("localhost", 6379); Now you can send commands like sending from Jedis. jedis.sadd("planets", "Venus"); Connecting to a Redis clusterJedis lets you connect to Redis Clusters, supporting the Redis Cluster Specification.
To do this, you'll need to connect using Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7380));
JedisCluster jedis = new JedisCluster(jedisClusterNodes); Now you can use the jedis.sadd("planets", "Mars"); Using Redis modulesJedis provides support for some of the Redis modules, most notably RedisJSON and RediSearch. See the RedisJSON Jedis or RediSearch Jedis for details. DocumentationThe Jedis wiki contains several useful articles for using Jedis. You can also check the latest Jedis Javadocs. TroubleshootingIf you run into trouble or have any questions, we're here to help! Hit us up on the Redis Discord Server or open an issue on GitHub. You can also find help on the Jedis mailing list or the GitHub Discussions. LicenseJedis is licensed under the MIT license. Sponsorship |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论