$ show leonchen83/redis-replicator
redis-replicator is a Java library for Redis replication and data parsing. It provides event-driven APIs to consume Redis RDB snapshots, AOF logs, and live replication streams (PSYNC/SCAN). The architecture is based on a `Replicator` interface with multiple implementations (`RedisRdbReplicator`, `RedisAofReplicator`, `RedisSocketReplicator`, `RedisMixReplicator`, `RedisScanReplicator`). Key entry points are `RedisReplicator` (facade) and `Configuration` (URI-based settings). Data flows: raw bytes from Redis or files are parsed by `RdbParser` or `CommandParser` into typed `Event` objects (e.g., `KeyValuePair`, `Command`), which are dispatched to registered `EventListener` instances. The library supports all major Redis data types, commands, and versions 2.6–8.4.x, with extensions for Valkey and custom modules. External dependencies include SLF4J for logging and Jedis for online tests. It is used for data migration, backup, real-time synchronization, and building custom Redis-compatible tools.
The LLM identified 5 files worth highlighting for reuse:
A `Map` implementation using `byte[]` as keys, backed by an array of `Element` objects. It provides efficient lookup and iteration for binary keys without boxing or string conversion. Reusable in any Java project that needs a map with byte array keys, such as protocol parsers or binary data stores.
A CRC64 checksum implementation using a precomputed lookup table. It supports incremental updates and finalization. Reusable for data integrity verification in any application that requires a 64-bit CRC, such as file validation or network protocol checksums.
LZF compression and decompression utility with thread-local state for performance. It handles both compress and decompress operations on byte arrays. Reusable in any Java project needing fast, lightweight compression, especially for streaming or RDB-like binary formats.
A URI parser for Redis connection strings (e.g., `redis://host:port?authPassword=...&ssl=yes`). It extracts host, port, authentication, SSL settings, and other query parameters, merging them into a `Configuration` object. Reusable in any Redis client or tool that needs to parse Redis URIs with extended options.
An `EventListener` decorator that batches events and delegates to a wrapped listener. It collects events until a configurable batch size is reached, then flushes them. Reusable for any event-driven system that needs to reduce callback frequency or process events in batches for efficiency.