[Open Source] A lightweight Redis client developed based on smart-socket, designed for the Java platform

Open SourceClassification Systems
2026-06-28 09:09 6 次浏览 • 0 次下载 0KB
[Open Source] A lightweight Redis client developed based on smart-socket, designed for the Java platform

1. Project Overview

Redisun is a lightweight Redis client developed based on smart-socket, specifically designed for the Java platform. It supports asynchronous, non-blocking I/O operations and provides high-performance Redis connections and command execution.

Redisun is continuously expanding its support for Redis commands. For the complete command list and support status, please refer to our View Supported Commands page.

2. Open Source License

Licensed under Apache-2.0

3. Screenshots

Image
Image

4. Feature Overview

Features

  • Lightweight
    The core code consists of only a few classes, and the JAR package is just 50 KB
  • High Performance
    Built on smart-socket Java AIO, offering strong single-threaded processing capabilities
  • Connection Reuse
    A single connection can handle multiple concurrent requests
  • Extensible
    Provides a simple and easy-to-use command extension interface for adding custom Redis commands

Core Components

  • Redisun
    Core client class providing connection management and command execution
  • Command
    Abstract base class for Redis commands, supporting custom command extensions
  • RESP
    Redis serialization protocol parser supporting multiple data types
  • RedisMessageProcessor
    Message handler responsible for parsing Redis server responses
  • RedisSession
    Session manager that maintains session state between the client and server
  • RedisunOptions
    Client configuration options class for setting connection parameters

5. Tech Stack

Installation

Maven

<dependency>
    <groupId>tech.smartboot</groupId>
    <artifactId>redisun</artifactId>
    <version>1.1.0</version>
</dependency>

Gradle

implementation 'tech.smartboot:redisun:1.0.0'

Quick Start

Basic Usage

import tech.smartboot.redisun.Redisun;
Redisun redisun = Redisun.create(options -> {
    options.setAddress("redis://127.0.0.1:6379");
    // Or use an address with authentication credentials
    // options.setAddress("redis://username:password@127.0.0.1:6379");
});
// Set a key-value pair
boolean setResult = redisun.set("mykey", "myvalue");
System.out.println("SET command result: " + setResult);
// Get a key-value pair
String getResult = redisun.get("mykey");
System.out.println("GET command result: " + getResult);
// Execute sorted set commands
int zaddResult = redisun.zadd("myzset", 1.0, "member1");
System.out.println("ZADD command result: " + zaddResult);
// Delete a key
int delResult = redisun.del("mykey");
System.out.println("DEL command result: " + delResult);
redisun.close();

Advanced Usage of the SET Command

Redisun redisun = Redisun.create(options -> {
    options.setAddress("redis://127.0.0.1:6379");
});
// Basic setting
redisun.set("key1", "value1");
// Set only if the key does not exist (NX option)
boolean nxResult = redisun.set("key2", "value2", cmd -> cmd.setIfNotExists());
// Set only if the key exists (XX option)
boolean xxResult = redisun.set("key1", "newvalue", cmd -> cmd.setIfExists());
// Set expiration time (seconds)
redisun.set("key3", "value3", cmd -> cmd.expire(60));
// Set expiration time (milliseconds)
redisun.set("key4", "value4", cmd -> cmd.expireMs(30000));
// Set expiration at a specific time
redisun.set("key5", "value5", cmd -> cmd.expireAt(new Date(System.currentTimeMillis() + 60000)));
// Keep the key's time to live
redisun.set("key1", "anotherValue", cmd -> cmd.keepTTL());
redisun.close();

Advanced Configuration

Redisun redisun = Redisun.create(options -> {
    // Set server address
    options.setAddress("redis://127.0.0.1:6379")
           // Set database
           .setDatabase(1)
           // Enable debug mode
           .debug(true);
});

Build and Test

Make sure Maven is installed, then run the following command:

mvn clean package

Run tests:

mvn test
#1
资源直链https://gitee.com/smartboot/redisun
去下载
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare