Giter Club home page Giter Club logo

redis-jdbc's Introduction

README

It is a JDBC Driver for Redis which is based on Jedis.

URL:

Features

  • Supports both single-node Redis and Redis Cluster.
  • Supports all the Redis Command that Jedis supports.
  • Support to connect Redis or Redis Cluster in Intellij IDEA database console. see: 如何在IntelliJ IDEA数据库控制台操作Redis
  • Support all JDBC-based ORM frameworks(aka. Mybatis or Hibernate).

How to use it?

Add the driver to your project:

 <dependency>
    <groupId>com.itmuch.redis</groupId>
    <artifactId>redis-jdbc</artifactId>
    <version>0.0.1</version>
</dependency>

For Redis

Just use like below:

Class.forName("com.itmuch.redis.jdbc.redis.RedisDriver");

Connection connection = DriverManager.getConnection(
  "jdbc:redis://localhost:6379/0",
  properties
);
Statement statement = connection.createStatement();

connection.setSchema("11");
ResultSet rs = statement.executeQuery("get a");
while (rs.next()) {
  String string = rs.getString(0);
  System.out.println(string);
}

The properties can be like below:

key defaultValue description
user null the user of Redis
password null the password of user
ssl false whether to use ssl
timeout 1000 Jedis timeout

For Redis Cluster

Just use like below:

Class.forName("com.itmuch.redis.jdbc.cluster.RedisClusterDriver");

Connection connection = DriverManager.getConnection(
  "jdbc:redis-cluster:///localhost:6379;localhost:6380;localhost:6381",
  properties
);
Statement statement = connection.createStatement();

connection.setSchema("11");
ResultSet rs = statement.executeQuery("get a");
while (rs.next()) {
  String string = rs.getString(0);
  System.out.println(string);
}

The properties can be like below:

key defaultValue description
user null the user of Redis
password null the password of user
ssl false whether to use ssl
timeout 1000 Jedis timeout
maxAttempts 5 Jedis maxAttempts

For Redis Sentinel

Not Support yet.

Thanks

Jedis

redis-jdbc's People

Contributors

eacdy avatar javalover123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.