Redisun is a lightweight, high-performance Redis client based on smart-socket designed for the Java platform. It supports asynchronous non-blocking I/O operations and provides memory key-value storage access capabilities compatible with Redis servers.
💡 Core Features
Lightweight Design : The core code consists of only a few classes, the jar package is only 33KB, and resource usage is minimal
High-Performance Communication : Based on smart-socket Java AIO implementation, strong single-threaded processing capabilities, low resource consumption
Connection Multiplexing Technology : Innovative connection multiplexing mechanism, one connection can handle multiple concurrent requests simultaneously
RESP Protocol Support : Complete support for Redis Serialization Protocol (RESP), compatible with Redis servers
Here is a simple usage example showing how to use Redisun for basic Redis operations:
import tech.smartboot.redisun.Redisun ;
public class BasicExample {
public static void main ( String [] args ) {
// Create Redisun client instance
Redisun redisun = Redisun . create ( options ->
options . setAddress ( " 127.0.0.1:6379 " ) // Set Redis server address
. debug ( true ) // Enable debug mode
boolean setResult = redisun . set ( " hello " , " world " ) ;
System . out . println ( " SET operation result: " + setResult ) ;
String getResult = redisun . get ( " hello " ) ;
System . out . println ( " GET operation result: " + getResult ) ;
int delResult = redisun . del ( " hello " ) ;
System . out . println ( " DEL operation result: " + delResult ) ;
// Close client, release resources
Redisun also supports more Redis commands, such as sorted set operations:
// Add elements to sorted set
int zaddResult = redisun . zadd ( " myzset " , 1.0 , " member1 " ) ;
System . out . println ( " ZADD operation result: " + zaddResult ) ;
// Optional parameter settings
boolean setResultWithOptions = redisun . set ( " key " , " value " , cmd ->
cmd . expire ( 60 ) // Set 60-second expiration
. setIfNotExists () // Set only if key does not exist
System . out . println ( " SET operation with options result: " + setResultWithOptions ) ;
Through these examples, you can see that Redisun’s API design is simple and intuitive, making it easy to integrate into your projects.
Redisun is continuously expanding support for Redis commands. Here is the current command implementation status:
Command Description Implementation Class Notes HELLOServer handshake and authentication HelloCommand Supports authentication and protocol negotiation SETSet key-value pairs SetCommand Complete option support: NX, XX, EX, PX, PXAT, KEEPTTL GETGet the value of a key GetCommand Basic key-value retrieval DELDelete one or more keys DelCommand Supports multi-key deletion ZADDAdd members to sorted set ZAddCommand Basic sorted set member addition SELECTSwitch database SelectCommand Only executed during initial connection, does not support runtime switching DBSIZEReturn the number of keys in the current database DBSizeCommand Count keys in current database FLUSHALLClear all databases FlushAllCommand Delete keys from all databases FLUSHDBClear current database FlushDbCommand Clear current database EXISTSCheck if key exists ExistsCommand Check if one or more keys exist INCRIncrement the integer value of a key by one IncrCommand Atomic increment operation DECRDecrement the integer value of a key by one DecrCommand Atomic decrement operation APPENDAppend a value to a key AppendCommand String append operation STRLENGet the length of a key’s value StrlenCommand String length operation HSETSet the string value of a hash field HSetCommand Hash field set operation HGETGet the value of a hash field HGetCommand Hash field get operation SADDAdd one or more members to a set SAddCommand Set member add operation INCRBYIncrement the integer value of a key by the given number IncrByCommand Atomic increment operation DECRBYDecrement the integer value of a key by the given number DecrByCommand Atomic decrement operation MGETGet the values of all given keys MGetCommand Get multiple key values MSETSet multiple key-value pairs MSetCommand Set multiple key-value pairs EXPIRESet a timeout on a key ExpireCommand Supports NX, XX, GT, LT options TTLGet the time to live for a key TtlCommand Returns the remaining lifetime of a key in seconds TYPEDetermine the type stored at a key TypeCommand Returns the type stored at a key LPUSHInsert elements at the head of a list LPushCommand Insert one or more elements at the head of a list RPUSHInsert elements at the tail of a list RPushCommand Insert one or more elements at the tail of a list LPOPRemove and return the first element of a list LPopCommand Remove and return the first element of a list RPOPRemove and return the last element of a list RPopCommand Remove and return the last element of a list ZREMRemove members from a sorted set ZRemCommand Remove one or more members from a sorted set ZRANGEReturn a range of members in a sorted set ZRangeCommand Return members in a specified index range of a sorted set ZSCOREGet the score associated with the given member in a sorted set ZScoreCommand Get the score of a specified member in a sorted set
We are actively expanding Redis command support. More commands will be included in future versions.
Redisun provides a powerful extension mechanism. You can easily implement custom Redis commands by extending the Command base class. This makes it simple to add support for any Redis commands not yet built into the library.
For detailed information on using custom commands to extend Redisun, please refer to our Extension Guide .