Carade v0.3.0 #3

Merged
irammini merged 47 commits from dev into main 2025-12-26 01:15:39 +00:00
irammini commented 2025-12-21 18:53:39 +00:00 (Migrated from github.com)

Goal: 60-70% compatibility with Redis

**Goal:** 60-70% compatibility with Redis
irammini commented 2025-12-21 19:35:12 +00:00 (Migrated from github.com)

In this commit:

Implemented "useful" commands:

  • List: LLEN, LINDEX, LREM
  • Hash: HLEN, HKEYS, HVALS, HEXISTS
  • String: STRLEN, GETSET
  • ZSet: ZREMRANGEBYSCORE, ZREMRANGEBYRANK
  • Set/Random: SPOP, SRANDMEMBER, RANDOMKEY

Organized into core/commands subpackages and registered in CommandRegistry.

In this commit: Implemented "useful" commands: - List: LLEN, LINDEX, LREM - Hash: HLEN, HKEYS, HVALS, HEXISTS - String: STRLEN, GETSET - ZSet: ZREMRANGEBYSCORE, ZREMRANGEBYRANK - Set/Random: SPOP, SRANDMEMBER, RANDOMKEY Organized into core/commands subpackages and registered in CommandRegistry.
irammini commented 2025-12-21 21:03:04 +00:00 (Migrated from github.com)

In this commit:

  • Migrated from raw ServerSocket to Netty 4.1.
  • Implemented RESP Decoder/Encoder using Netty handlers.
  • Refactored ClientHandler to ChannelInboundHandlerAdapter.
  • Added Maven build system (pom.xml).
  • Fixed transaction logic (MULTI/EXEC) to work with Netty pipeline.
  • Verified basic commands and transaction atomicity.
In this commit: - Migrated from raw ServerSocket to Netty 4.1. - Implemented RESP Decoder/Encoder using Netty handlers. - Refactored ClientHandler to ChannelInboundHandlerAdapter. - Added Maven build system (pom.xml). - Fixed transaction logic (MULTI/EXEC) to work with Netty pipeline. - Verified basic commands and transaction atomicity.
irammini commented 2025-12-21 21:53:51 +00:00 (Migrated from github.com)

In this commit:

  • Replaced manual config parsing with Jackson YAML parser (with legacy fallback).
  • Replaced LZF compression in RDB persistence with LZ4 for writing, while maintaining LZF read support for backward compatibility.
In this commit: - Replaced manual config parsing with Jackson YAML parser (with legacy fallback). - Replaced LZF compression in RDB persistence with LZ4 for writing, while maintaining LZF read support for backward compatibility.
irammini commented 2025-12-21 22:31:39 +00:00 (Migrated from github.com)

In this commit:

  • Implemented BITCOUNT and BITOP commands (AND, OR, XOR, NOT) in core.commands.string.
  • Added Slowlog functionality: logging queries > 10ms in Carade.slowLog and a SLOWLOG command.
  • Enhanced eviction policy to support LFU by adding frequency tracking in ValueEntry.
  • Added HyperLogLog support (PFADD, PFCOUNT) with a new DataType and struct implementation.
  • Updated CommandRegistry and ClientHandler to support new commands and logic.
In this commit: - Implemented BITCOUNT and BITOP commands (AND, OR, XOR, NOT) in core.commands.string. - Added Slowlog functionality: logging queries > 10ms in Carade.slowLog and a SLOWLOG command. - Enhanced eviction policy to support LFU by adding frequency tracking in ValueEntry. - Added HyperLogLog support (PFADD, PFCOUNT) with a new DataType and struct implementation. - Updated CommandRegistry and ClientHandler to support new commands and logic.
irammini commented 2025-12-21 23:08:06 +00:00 (Migrated from github.com)

In this commit:

  • Added DataType.JSON to core.db.DataType
  • Implemented JsonSetCommand and JsonGetCommand using Jackson
  • Added JsonUtils for path traversal
  • Registered new commands in CommandRegistry
In this commit: - Added DataType.JSON to core.db.DataType - Implemented JsonSetCommand and JsonGetCommand using Jackson - Added JsonUtils for path traversal - Registered new commands in CommandRegistry
irammini commented 2025-12-22 10:36:47 +00:00 (Migrated from github.com)

In this commit:

  • Implemented SORT command with support for BY, LIMIT, GET, ASC/DESC, ALPHA, and STORE.
  • Added SINTERSTORE, SUNIONSTORE, SDIFFSTORE for Set operations.
  • Added ZUNIONSTORE and ZINTERSTORE for Sorted Set operations with WEIGHTS and AGGREGATE.
  • Implemented BRPOPLPUSH with proper database isolation.
  • Added APPEND, GETRANGE, SETRANGE commands.
  • Enhanced SCAN to support TYPE filtering.
  • Improved error handling in ClientHandler and command execution flow.
In this commit: - Implemented `SORT` command with support for `BY`, `LIMIT`, `GET`, `ASC/DESC`, `ALPHA`, and `STORE`. - Added `SINTERSTORE`, `SUNIONSTORE`, `SDIFFSTORE` for Set operations. - Added `ZUNIONSTORE` and `ZINTERSTORE` for Sorted Set operations with `WEIGHTS` and `AGGREGATE`. - Implemented `BRPOPLPUSH` with proper database isolation. - Added `APPEND`, `GETRANGE`, `SETRANGE` commands. - Enhanced `SCAN` to support `TYPE` filtering. - Improved error handling in `ClientHandler` and command execution flow.
irammini commented 2025-12-22 11:48:55 +00:00 (Migrated from github.com)

In this commit:

  • Sorted Sets: Added ZPOPMIN and ZPOPMAX for efficient score-based popping.
  • Hash: Added HSETNX and HINCRBYFLOAT.
  • List: Added LMOVE and BLMOVE for flexible list manipulation.
  • Async Delete: Implemented UNLINK which performs key removal immediately and value cleanup asynchronously.
  • Bloom Filter: Added BloomFilter struct and BF.ADD / BF.EXISTS commands.
  • Updated ClientHandler to support these new commands and fixed formatting for float responses.
In this commit: - Sorted Sets: Added `ZPOPMIN` and `ZPOPMAX` for efficient score-based popping. - Hash: Added `HSETNX` and `HINCRBYFLOAT`. - List: Added `LMOVE` and `BLMOVE` for flexible list manipulation. - Async Delete: Implemented `UNLINK` which performs key removal immediately and value cleanup asynchronously. - Bloom Filter: Added `BloomFilter` struct and `BF.ADD` / `BF.EXISTS` commands. - Updated `ClientHandler` to support these new commands and fixed formatting for float responses.
irammini commented 2025-12-22 12:36:54 +00:00 (Migrated from github.com)

In this commit:

Moved the following commands from ClientHandler.java switch-case to standalone classes in core.commands:

  • Hash: HDEL, HINCRBY, HSETNX, HINCRBYFLOAT
  • Set: SMEMBERS, SREM, SISMEMBER, SCARD, SINTER, SUNION, SDIFF, SINTERSTORE, SUNIONSTORE, SDIFFSTORE

Registered all new commands in CommandRegistry.
Removed the legacy switch-case blocks for these commands in ClientHandler.java.

In this commit: Moved the following commands from `ClientHandler.java` switch-case to standalone classes in `core.commands`: - Hash: HDEL, HINCRBY, HSETNX, HINCRBYFLOAT - Set: SMEMBERS, SREM, SISMEMBER, SCARD, SINTER, SUNION, SDIFF, SINTERSTORE, SUNIONSTORE, SDIFFSTORE Registered all new commands in `CommandRegistry`. Removed the legacy switch-case blocks for these commands in `ClientHandler.java`.
irammini commented 2025-12-22 13:50:44 +00:00 (Migrated from github.com)

In this commit:

  • Extracted all commands from the massive switch-case in ClientHandler to separate classes in core.commands.* packages.
  • Updated CommandRegistry to register the new commands.
  • Updated ClientHandler to delegate command execution to CommandRegistry.
  • Added necessary public accessors and helper methods to ClientHandler to support the extracted commands.
  • Verified functionality including transactions (MULTI/EXEC), SCAN, and basic KV operations.
In this commit: - Extracted all commands from the massive switch-case in ClientHandler to separate classes in core.commands.* packages. - Updated CommandRegistry to register the new commands. - Updated ClientHandler to delegate command execution to CommandRegistry. - Added necessary public accessors and helper methods to ClientHandler to support the extracted commands. - Verified functionality including transactions (MULTI/EXEC), SCAN, and basic KV operations.
irammini commented 2025-12-22 19:20:01 +00:00 (Migrated from github.com)

In this commit:

  • Added MonitorCommand class in core.commands.server.
  • Registered MONITOR in Carade.java.
  • Updated ClientHandler to:
    • Track isMonitor state.
    • Maintain a global monitors set in Carade.
    • Broadcast all executed commands (except AUTH/QUIT) to active monitors.
    • Block other commands (except QUIT) when in monitor mode.
    • Format broadcast messages with standard Redis timestamp and client info.
  • Cleaned up monitors on client disconnection.
In this commit: - Added `MonitorCommand` class in `core.commands.server`. - Registered `MONITOR` in `Carade.java`. - Updated `ClientHandler` to: - Track `isMonitor` state. - Maintain a global `monitors` set in `Carade`. - Broadcast all executed commands (except AUTH/QUIT) to active monitors. - Block other commands (except QUIT) when in monitor mode. - Format broadcast messages with standard Redis timestamp and client info. - Cleaned up monitors on client disconnection.
irammini commented 2025-12-23 05:12:39 +00:00 (Migrated from github.com)

In this commit:

  • Updated CommandRegistry to properly register HEXPIRE and HTTL.
  • Updated CaradeHash to support expiration logic.
  • Ensured all hash commands are refactored to use CaradeHash.
  • Fixed AOF replay logic for hash commands.
In this commit: - Updated `CommandRegistry` to properly register `HEXPIRE` and `HTTL`. - Updated `CaradeHash` to support expiration logic. - Ensured all hash commands are refactored to use `CaradeHash`. - Fixed AOF replay logic for hash commands.
irammini commented 2025-12-23 11:41:36 +00:00 (Migrated from github.com)

In this commit:

  • Implemented T-Digest probabilistic data structure (core.structs.tdigest)
  • Added TD.ADD, TD.QUANTILE, TD.INFO commands
  • Updated CommandRegistry to include TD commands and fix missing GET/DEL
In this commit: - Implemented T-Digest probabilistic data structure (core.structs.tdigest) - Added TD.ADD, TD.QUANTILE, TD.INFO commands - Updated CommandRegistry to include TD commands and fix missing GET/DEL
irammini commented 2025-12-23 14:01:54 +00:00 (Migrated from github.com)

In this commit:

  • Added RENAMENX in RenameNxCommand.
  • Added SWAPDB in SwapDbCommand (Server group).
  • Added MOVE in MoveCommand.
  • Added COPY in CopyCommand with deep copy support.
  • Added EXPIRETIME and PEXPIRETIME in ExpireTimeCommand and PExpireTimeCommand.
  • Implemented copy() method in ValueEntry and supporting structs (CaradeZSet, BloomFilter, HyperLogLog, TDigest, Centroid) to enable COPY command.
  • Updated CommandRegistry to register new commands.
  • Fixed TDigestTest to use JUnit 5.
In this commit: - Added `RENAMENX` in `RenameNxCommand`. - Added `SWAPDB` in `SwapDbCommand` (Server group). - Added `MOVE` in `MoveCommand`. - Added `COPY` in `CopyCommand` with deep copy support. - Added `EXPIRETIME` and `PEXPIRETIME` in `ExpireTimeCommand` and `PExpireTimeCommand`. - Implemented `copy()` method in `ValueEntry` and supporting structs (`CaradeZSet`, `BloomFilter`, `HyperLogLog`, `TDigest`, `Centroid`) to enable `COPY` command. - Updated `CommandRegistry` to register new commands. - Fixed `TDigestTest` to use JUnit 5.
irammini commented 2025-12-24 03:12:57 +00:00 (Migrated from github.com)

In this commit:

Implemented several missing Redis commands across various categories:

  • List: LINSERT
  • Set: SMISMEMBER
  • HyperLogLog: PFMERGE
  • ZSet (Lex): ZLEXCOUNT, ZRANGEBYLEX, ZREMRANGEBYLEX
  • ZSet (Diff/Inter/Union): ZDIFF, ZDIFFSTORE, ZINTER, ZUNION
  • Server: SAVE, BGSAVE, LASTSAVE, SHUTDOWN, ROLE
  • Connection: CLIENT (ID, LIST, KILL)

Refactored Carade.java to support tracking connected clients and safe background saving.
Deleted unused LexUtils.java created during development.

In this commit: Implemented several missing Redis commands across various categories: - List: LINSERT - Set: SMISMEMBER - HyperLogLog: PFMERGE - ZSet (Lex): ZLEXCOUNT, ZRANGEBYLEX, ZREMRANGEBYLEX - ZSet (Diff/Inter/Union): ZDIFF, ZDIFFSTORE, ZINTER, ZUNION - Server: SAVE, BGSAVE, LASTSAVE, SHUTDOWN, ROLE - Connection: CLIENT (ID, LIST, KILL) Refactored `Carade.java` to support tracking connected clients and safe background saving. Deleted unused `LexUtils.java` created during development.
irammini commented 2025-12-24 12:47:11 +00:00 (Migrated from github.com)

In this commit:

Implemented additional Redis commands across various categories:

  • PubSub: PUBSUB (CHANNELS, NUMSUB, NUMPAT)
  • ZSet: ZINTERCARD, ZRANGESTORE
  • Geo: GEORADIUSBYMEMBER
  • Bitmap: BITPOS
  • Generic: DUMP, RESTORE, OBJECT (ENCODING, IDLETIME, REFCOUNT, FREQ)
  • Server: COMMAND (COUNT, DOCS)
  • Connection: CLIENT PAUSE, CLIENT UNPAUSE

Enhanced RdbEncoder to support single-value encoding for DUMP.
Implemented client pausing mechanism in Carade and ClientHandler.

In this commit: Implemented additional Redis commands across various categories: - PubSub: PUBSUB (CHANNELS, NUMSUB, NUMPAT) - ZSet: ZINTERCARD, ZRANGESTORE - Geo: GEORADIUSBYMEMBER - Bitmap: BITPOS - Generic: DUMP, RESTORE, OBJECT (ENCODING, IDLETIME, REFCOUNT, FREQ) - Server: COMMAND (COUNT, DOCS) - Connection: CLIENT PAUSE, CLIENT UNPAUSE Enhanced `RdbEncoder` to support single-value encoding for `DUMP`. Implemented client pausing mechanism in `Carade` and `ClientHandler`.
irammini commented 2025-12-24 15:56:17 +00:00 (Migrated from github.com)

In this commit:

Implemented INCRBYFLOAT, SMOVE, ZRANDMEMBER, CONFIG (SET/RESETSTAT), RESET, LMPOP, BLMPOP, LCS, LOLWUT, SORT_RO, and fixed HSCAN in ScanCommand. Also updated ClientCommand for ID/KILL.

In this commit: Implemented INCRBYFLOAT, SMOVE, ZRANDMEMBER, CONFIG (SET/RESETSTAT), RESET, LMPOP, BLMPOP, LCS, LOLWUT, SORT_RO, and fixed HSCAN in ScanCommand. Also updated ClientCommand for ID/KILL.
irammini commented 2025-12-24 17:06:36 +00:00 (Migrated from github.com)

In this commit:

  • Scan Family: HSCAN, SSCAN, ZSCAN
  • Blocking ZSet: BZPOPMAX, BZPOPMIN (with generic blocking support in Carade.java)
  • Geo: GEOSEARCH, GEOSEARCHSTORE
  • Bitwise: BITFIELD, BITFIELD_RO
  • Memory & Diagnostic: MEMORY USAGE, MEMORY STATS, LATENCY (stub)
  • Replication: WAIT (stub), MIGRATE
  • Client Admin: CLIENT ID, CLIENT KILL, CLIENT LIST
  • ZSet Compatibility: ZREVRANGEBYLEX, ZREVRANGEBYSCORE

Refactored CLIENT command to use dedicated classes. Introduced MEMORY router command. Updated CommandRegistry for all new commands.

In this commit: - Scan Family: `HSCAN`, `SSCAN`, `ZSCAN` - Blocking ZSet: `BZPOPMAX`, `BZPOPMIN` (with generic blocking support in `Carade.java`) - Geo: `GEOSEARCH`, `GEOSEARCHSTORE` - Bitwise: `BITFIELD`, `BITFIELD_RO` - Memory & Diagnostic: `MEMORY USAGE`, `MEMORY STATS`, `LATENCY` (stub) - Replication: `WAIT` (stub), `MIGRATE` - Client Admin: `CLIENT ID`, `CLIENT KILL`, `CLIENT LIST` - ZSet Compatibility: `ZREVRANGEBYLEX`, `ZREVRANGEBYSCORE` Refactored `CLIENT` command to use dedicated classes. Introduced `MEMORY` router command. Updated `CommandRegistry` for all new commands.
irammini commented 2025-12-24 18:05:00 +00:00 (Migrated from github.com)

This commit introduces a fully functional Lua scripting engine using luaj-jse.

Key features:

  • EVAL and EVALSHA commands support.
  • SCRIPT LOAD, SCRIPT EXISTS, SCRIPT FLUSH commands.
  • redis.call and redis.pcall binding for executing commands from Lua.
  • SHA1 script caching in ScriptManager.
  • Sandboxed Lua environment (restricted to safe libraries: base, table, string, math, debug).
  • Robust type conversion (LuaConverter) handling binary safety and Redis protocol mapping (e.g., Simple Strings -> {ok: ...}).
  • Integration with ClientHandler to capture command output during script execution.

Tests included for type conversion and binary safety.

This commit introduces a fully functional Lua scripting engine using `luaj-jse`. Key features: - `EVAL` and `EVALSHA` commands support. - `SCRIPT LOAD`, `SCRIPT EXISTS`, `SCRIPT FLUSH` commands. - `redis.call` and `redis.pcall` binding for executing commands from Lua. - SHA1 script caching in `ScriptManager`. - Sandboxed Lua environment (restricted to safe libraries: base, table, string, math, debug). - Robust type conversion (`LuaConverter`) handling binary safety and Redis protocol mapping (e.g., Simple Strings -> `{ok: ...}`). - Integration with `ClientHandler` to capture command output during script execution. Tests included for type conversion and binary safety.
irammini commented 2025-12-24 18:43:31 +00:00 (Migrated from github.com)

In this commit:

  • Replaced brittle executeInternal switch-case with executeAofCommand that leverages CommandRegistry for robust and maintainable AOF replay.
  • Refactored Janitor thread to use a stochastic, high-frequency (100ms) active expiration loop to reduce latency spikes, and a separate low-frequency (30s) maintenance loop for heavy tasks.
  • Updated ReplicationManager to use the new executeAofCommand logic.
In this commit: - Replaced brittle `executeInternal` switch-case with `executeAofCommand` that leverages `CommandRegistry` for robust and maintainable AOF replay. - Refactored `Janitor` thread to use a stochastic, high-frequency (100ms) active expiration loop to reduce latency spikes, and a separate low-frequency (30s) maintenance loop for heavy tasks. - Updated `ReplicationManager` to use the new `executeAofCommand` logic.
irammini commented 2025-12-24 18:56:27 +00:00 (Migrated from github.com)

In this commit:

  • Fixed ReplicationManager offset reporting to use WriteSequencer backlog.
  • Implemented non-blocking WAIT command (returns connected replica count immediately).
  • Enhanced PSYNC to support Partial Resync via backlog before falling back to full RDB sync.
In this commit: - Fixed `ReplicationManager` offset reporting to use `WriteSequencer` backlog. - Implemented non-blocking `WAIT` command (returns connected replica count immediately). - Enhanced `PSYNC` to support Partial Resync via backlog before falling back to full RDB sync.
irammini commented 2025-12-25 03:51:03 +00:00 (Migrated from github.com)

In this commit:

Introduces the following commands:

  • BF.MADD: Batch add items to a Bloom Filter.
  • BF.MEXISTS: Batch check existence in a Bloom Filter.
  • JSON.DEL: Delete a value at a specific path (or the whole key).
  • JSON.TYPE: Get the type of the value at a specific path.
  • ZMPOP: Pop elements from multiple Sorted Sets.
  • BZMPOP: Blocking variant of ZMPOP.
  • SINTERCARD: Calculate the cardinality of set intersection without returning elements.
  • TD.CDF: Calculate Cumulative Distribution Function for T-Digest.

Also includes fixes for exception handling in JSON.DEL and correct response formatting for BF commands.

Finally, removes every tests.

In this commit: Introduces the following commands: - BF.MADD: Batch add items to a Bloom Filter. - BF.MEXISTS: Batch check existence in a Bloom Filter. - JSON.DEL: Delete a value at a specific path (or the whole key). - JSON.TYPE: Get the type of the value at a specific path. - ZMPOP: Pop elements from multiple Sorted Sets. - BZMPOP: Blocking variant of ZMPOP. - SINTERCARD: Calculate the cardinality of set intersection without returning elements. - TD.CDF: Calculate Cumulative Distribution Function for T-Digest. Also includes fixes for exception handling in JSON.DEL and correct response formatting for BF commands. Finally, removes every tests.
irammini commented 2025-12-25 15:12:39 +00:00 (Migrated from github.com)

In this commit:

  • Replaced System.out/err.println with core.utils.Log wrapper.
  • Refactored Janitor thread to use ScheduledExecutorService.
  • Added deprecation warning for loadLegacyData.
In this commit: - Replaced System.out/err.println with core.utils.Log wrapper. - Refactored Janitor thread to use ScheduledExecutorService. - Added deprecation warning for loadLegacyData.
irammini commented 2025-12-25 15:35:33 +00:00 (Migrated from github.com)

In this commit:

  • Bump version to 0.3.0 in README and POM, also in InfoCommand.
  • Update Dockerfile to use Maven multi-stage build.
  • Update README with new features (JSON, Lua, etc.).
  • Add maven-shade-plugin to POM for uber-jar creation.
In this commit: - Bump version to 0.3.0 in README and POM, also in InfoCommand. - Update Dockerfile to use Maven multi-stage build. - Update README with new features (JSON, Lua, etc.). - Add maven-shade-plugin to POM for uber-jar creation.
irammini commented 2025-12-26 00:29:47 +00:00 (Migrated from github.com)

In this commit:

  • Added ClientHandler reference to BlockingRequest to enable tracking of requests by client.
  • Implemented Carade.removeBlockingRequests(ClientHandler) to clean up pending blocking requests when a client disconnects, preventing memory leaks.
  • Updated ClientHandler.cleanup() to invoke the new blocking request removal logic.
  • Updated all blocking commands (BLPOP, BRPOP, BLMOVE, etc.) to pass the ClientHandler when creating BlockingRequest.
  • Added Carade.shutdownInitiated flag to coordinate shutdown sequence.
  • Updated ShutdownCommand to set shutdownInitiated = true.
  • Updated Carade.saveData to log a warning instead of throwing a RuntimeException if a save is already in progress.
  • Updated Carade shutdown hook to check shutdownInitiated before attempting a save, preventing double-save attempts and crash logs.
In this commit: - Added `ClientHandler` reference to `BlockingRequest` to enable tracking of requests by client. - Implemented `Carade.removeBlockingRequests(ClientHandler)` to clean up pending blocking requests when a client disconnects, preventing memory leaks. - Updated `ClientHandler.cleanup()` to invoke the new blocking request removal logic. - Updated all blocking commands (`BLPOP`, `BRPOP`, `BLMOVE`, etc.) to pass the `ClientHandler` when creating `BlockingRequest`. - Added `Carade.shutdownInitiated` flag to coordinate shutdown sequence. - Updated `ShutdownCommand` to set `shutdownInitiated = true`. - Updated `Carade.saveData` to log a warning instead of throwing a `RuntimeException` if a save is already in progress. - Updated `Carade` shutdown hook to check `shutdownInitiated` before attempting a save, preventing double-save attempts and crash logs.
Sign in to join this conversation.
No description provided.