@bcoders.gr/redis-client
Version:
High-performance Redis client with advanced compression, multi-level caching, bulk operations, and comprehensive performance monitoring. Optimized for production workloads with intelligent cache management.
158 lines (127 loc) • 8.24 kB
Markdown
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.2] - 2025-06-04
### Added
- **getNamespaceSnapshot()**: New method that provides a complete snapshot of all keys and values from a Redis namespace
- **Optimized Bulk Operations**: getNamespaceSnapshot leverages existing getBulkBatched operations for efficient data retrieval
- **Clean API**: Returns a clean object with namespace prefix removed from keys for easier data processing
### Features
- Automatically retrieves all keys from specified namespace using getNamespace()
- Removes namespace prefix from keys for cleaner result structure
- Uses optimized bulk batched operations for high performance
- Supports custom batch size parameter (default: 100)
- Comprehensive error handling with detailed logging
### Usage
```javascript
// Get all pairs from 'pair' namespace
const pairData = await client.getNamespaceSnapshot('pair');
// Custom batch size for large datasets
const blockData = await client.getNamespaceSnapshot('block', 200);
```
## [1.2.1] - 2025-06-04
### Fixed
- **Subscription Bug**: Fixed critical bug where multiple namespace subscriptions failed due to CONFIG SET being executed on subscription client
- **Multiple Subscriptions**: Now properly supports subscribing to multiple namespaces simultaneously
- **CONFIG Command**: Moved keyspace events configuration to main client instead of subscription client
- **Error Handling**: Added proper error handling for keyspace events configuration
### Technical Details
- The `subscribeToKeyspaceEvents()` method now executes `CONFIG SET notify-keyspace-events KEA` on the main client only once per instance
- Added `keyspaceEventsConfigured` flag to prevent redundant configuration calls
- This fixes the "ERR Can't execute 'config|set': only (P|S)SUBSCRIBE / (P|S)UNSUBSCRIBE / PING / QUIT / RESET are allowed in this context" error
## [1.2.0] - 2025-06-04
### Added
- **Multi-level Caching**: Added intelligent caching for compression, decompression, and key formatting operations
- **Performance Analytics**: Comprehensive performance statistics tracking with cache hit rates and timing metrics
- **Advanced Bulk Operations**: Parallel compression/decompression for bulk operations with configurable batching
- **High-Resolution Timing**: Switched to `performance.now()` for precise performance measurements
- **Memory Optimization**: Smart cache management with automatic cleanup and configurable size limits
- **Advanced Operations**: Added atomic counter operations (increment/decrement) and Lua script execution
- **Batched Operations**: Added `setBulkBatched()` and `getBulkBatched()` for processing large datasets in chunks
- **Cache Management**: Added `optimizeCaches()`, `clearCaches()`, and `resetPerformanceStats()` methods
- **Performance Testing**: Added comprehensive performance test suite (`performance-test.js`)
### Enhanced
- **Compression Caching**: Optimized compression with intelligent cache key generation and LRU-like behavior
- **Connection Management**: Extended connection cache TTL to 5 seconds for better performance
- **Key Formatting**: Added caching for formatted Redis keys to reduce string concatenation overhead
- **Error Handling**: Enhanced error handling with performance context in logging
- **Bulk Operations**: Optimized `setBulk()` and `getBulk()` with parallel processing
- **Pipeline Operations**: Improved pipeline efficiency with better batch size management
### Performance Improvements
- **Compression Speed**: Up to 60% faster compression operations through caching
- **Bulk Operations**: 40-70% performance improvement for bulk SET/GET operations
- **Memory Usage**: Reduced memory overhead through intelligent cache management
- **Connection Overhead**: Reduced connection checks through extended caching
- **JSON Processing**: Optimized JSON detection using Set-based character checking
### Technical
- Added performance constants: `COMPRESSION_CACHE_MAX_SIZE`, `CONNECTION_CACHE_TTL`, `BATCH_FLUSH_INTERVAL`, `PIPELINE_BATCH_SIZE`
- Enhanced constructor documentation with performance feature descriptions
- Added comprehensive performance statistics tracking
- Implemented cache size limits with automatic cleanup strategies
## [1.1.3] - 2025-06-04
### Fixed
- **Race Condition**: Fixed ClientClosedError in getNamespaceSize() and getKeys() methods
- **SCAN Operations**: Replaced problematic SCAN loops with simple KEYS command
- **Connection Stability**: Eliminated race conditions where SCAN operations continued after client disconnection
### Changed
- **getNamespaceSize()**: Now uses `client.keys()` instead of SCAN for better reliability
- **getKeys()**: Now uses `client.keys()` instead of SCAN for better reliability
- **Performance**: Simplified operations reduce complexity and eliminate hanging issues
## [1.1.2] - 2025-06-04
### Removed
- **Example File**: Removed example.js file to streamline package distribution
- **Example Script**: Removed npm run example script from package.json
- **Example Documentation**: Cleaned up README.md references to example usage
### Changed
- Updated package files list to exclude example.js
- Cleaner project structure focused on core functionality
- Fixed test suite cleanup to prevent hanging tests
## [1.1.1] - 2025-06-04
### Fixed
- **Race Condition Fix**: Fixed critical race condition where commands could be sent before Redis connection was established
- **Connection Promise Management**: Added proper promise tracking for both main and subscription client connections
- **Subscription Client Initialization**: Made `_initializeSubClient()` async and ensured connection is awaited before sending commands
- **Connection State Verification**: Enhanced `_ensureClientConnected()` to properly wait for ongoing connections
### Technical Improvements
- Added `subClientConnectionPromise` tracking for subscription client connections
- Enhanced error handling for connection timing issues
- Improved connection reliability for keyspace event subscriptions
## [1.1.0] - 2025-06-04
### Added
- Enhanced constructor to accept flexible connection options (socket path or IP address)
- Support for custom username and password parameters in constructor
- Backward compatibility with legacy boolean connection options
- Improved connection configuration handling for various Redis setups
### Changed
- Constructor signature now supports: `new RedisClient(alias, connectionOptions, username, password)`
- Documentation updated with comprehensive connection examples
## [1.0.0] - 2025-06-04
### Added
- Initial release of @bcoders/redis-client
- Built-in compression using zlib for all stored values
- Performance monitoring with configurable thresholds for slow operations
- Keyspace event subscriptions for real-time notifications
- Robust connection management with auto-reconnection
- Pipeline support for batch operations
- Namespace operations for easy key management
- Self-contained implementation without external utility dependencies
- Support for both local and remote Redis connections via Unix sockets
- Comprehensive error handling and logging
- EventEmitter integration for keyspace events
- Automatic JSON serialization/deserialization
- TTL support for key expiration
### Features
- **RedisClient Class**: Main client with alias support and connection management
- **Compression**: Automatic zlib compression/decompression for storage efficiency
- **Performance Monitoring**: Configurable thresholds for slow GET/SET operations
- **Subscriptions**: Keyspace event subscriptions with automatic re-subscription on reconnect
- **Pipeline Operations**: Batch operations using Redis MULTI/EXEC
- **Namespace Management**: Easy management of key namespaces with utility methods
- **Connection Handling**: Auto-reconnection and connection state management
### Technical Details
- Node.js >= 16.0.0 support
- ES Modules (type: "module")
- Redis client dependency (^4.6.0)
- Unix socket connections for optimal performance
- Built-in EventEmitter for real-time notifications