valkey_client 1.0.0
valkey_client: ^1.0.0 copied to clipboard
A modern, production-ready Dart client for Valkey (9.0.0+). Fully Redis 7.x compatible.
Changelog #
1.0.0 #
π First Production-Ready Stable Release (Standalone/Sentinel) π
This release marks the first stable version of valkey_client suitable for production use in Standalone and Sentinel environments. All core data types, transactions, and Pub/Sub features are implemented and tested.
Changed #
- Production-Ready Cleanup: Removed all internal debug
printstatements. - Error Handling: Replaced standard
Exceptionswith specific exception classes (ValkeyConnectionException,ValkeyServerException,ValkeyClientException,ValkeyParsingException) for robust error handling. - Logging: Added an internal lightweight logger (via
ValkeyClient.setLogLevel(ValkeyLogLevel)) instead of requiringpackage:logging. (Logging isOFFby default).
Fixed #
- Test Suite: Corrected several tests (e.g.,
WRONGTYPE,EXECABORT) to correctly expect the new specific exception types (ValkeyServerException). - Lints: Addressed
constant_identifier_nameslint forValkeyLogLevelviaanalysis_options.yaml.
Documentation #
- README.md: Updated to reflect
v1.0.0status. Added an Important Note regarding the lack of built-in connection pooling and recommendingpackage:pool. - API Reference: Added comprehensive Dart Doc comments for all public classes and methods in
valkey_client_base.dartandexceptions.dart.
0.12.0 #
Added #
- New Commands (Pub/Sub Introspection): Added commands to inspect the Pub/Sub system state. These commands do not require the client to be in Pub/Sub mode.
client.pubsubChannels([pattern]): Lists active channels.client.pubsubNumSub(channels): Returns aMapof channels and their subscriber counts.client.pubsubNumPat(): Returns the total number of pattern subscriptions.
0.11.0 #
Added #
- Transactions: Implemented basic transaction support.
client.multi(): Marks the start of a transaction block.client.exec(): Executes all queued commands and returns their replies as aList<dynamic>?.client.discard(): Flushes all commands queued in a transaction.
- Client State: The client now tracks transaction state (
_isInTransaction). Most commands sent during this state will return+QUEUED(which the client now handles).
0.10.0 #
Added #
- Advanced Pub/Sub: Completed the core Pub/Sub feature set.
client.unsubscribe(): Unsubscribes from specific channels or all channels.client.psubscribe(): Subscribes to patterns, returning aSubscriptionobject.client.punsubscribe(): Unsubscribes from specific patterns or all patterns.
pmessageHandling: The client now correctly parses and emitspmessage(pattern message) events via theValkeyMessagestream (withpatternfield populated).- State Management: Improved internal state management (
_isInPubSubMode,_resetPubSubState) for handling mixed and multiple subscription/unsubscription scenarios.
Fixed #
- Critical Pub/Sub Hang: Fixed a complex bug where
await unsubscribe()orawait punsubscribe()would hang (timeout).- Root Cause:
SUBSCRIBEandPSUBSCRIBEcommands were incorrectly leaving their commandCompleters in the_responseQueue. - Symptom: This caused the queue to become desynchronized, and subsequent
unsubscribe/punsubscribecalls would process the staleCompleterinstead of their own, leading to an infinite wait.
- Root Cause:
- Logic Refactor: The
executemethod is now corrected to not addCompleters to the_responseQueuefor any Pub/Sub management commands (SUBSCRIBE,PSUBSCRIBE,UNSUBSCRIBE,PUNSUBSCRIBE), as their futures are managed separately (e.g.,Subscription.readyor theFuture<void>returned byunsubscribe).
0.9.1 #
Note: This is the first version published to pub.flutter-io.cn with basic Pub/Sub support. Version 0.9.0 was unpublished due to bugs.
Fixed #
- Critical Pub/Sub Bug: Fixed the issue where the client would stop receiving Pub/Sub messages after the initial subscription confirmation, causing tests to time out. The root cause involved the handling of the
SUBSCRIBEcommand'sCompleterinterfering with theStreamSubscription. - Parser Logic: Improved the internal parser logic (
_processBuffer) to more reliably distinguish between Pub/Sub push messages and regular command responses, especially while in the subscribed state. - Test Logic: Corrected the authentication failure test (
should throw an Exception when providing auth...) to expect the actual error message returned by the server (ERR AUTH...) instead of a custom one.
Changed #
- Pub/Sub Example: Updated the Pub/Sub example (
example/valkey_client_example.dart) to reflect the correct usage with the newSubscriptionobject (includingawait sub.ready).
0.9.0 #
Note: This version was not published to pub.flutter-io.cn due to unresolved issues in the Pub/Sub implementation found during testing.
Added #
- New Commands (Pub/Sub): Added basic Publish/Subscribe functionality.
client.publish(): Posts a message to a channel.client.subscribe(): Subscribes to channels and returns aStream<ValkeyMessage>for receiving messages.
- Push Message Handling: The internal parser and client logic were updated to handle asynchronous push messages (like pub/sub messages) separate from command responses.
ValkeyMessageClass: Introduced a class to represent incoming pub/sub messages.
Known Limitations #
- Once subscribed, only
UNSUBSCRIBE,PUNSUBSCRIBE,PING, andQUITcommands are allowed by Redis/Valkey. The client currently enforces this restriction partially. Fullunsubscribelogic is not yet implemented. - Pattern subscription (
PSUBSCRIBE,PUNSUBSCRIBE) is not yet supported.
0.8.0 #
Added #
- New Commands (Key Management): Added commands for managing keys.
client.del()client.exists()client.expire()(set timeout in seconds)client.ttl()(get remaining time to live)
- These commands primarily return
Integerresponses.
0.7.0 #
Added #
- New Commands (Sets): Added commands for working with Sets.
client.sadd()/client.srem()client.smembers()
- New Commands (Sorted Sets): Added commands for working with Sorted Sets (leaderboards).
client.zadd()/client.zrem()client.zrange()(by index)
- These commands utilize the existing
Integer,Array, andBulk Stringparsers.
0.6.0 #
Added #
- New Commands (Lists): Added commands for working with Lists.
client.lpush()/client.rpush()client.lpop()/client.rpop()client.lrange()
- These commands utilize the existing
Integer,Bulk String, andArrayparsers.
0.5.0 #
Added #
- New Commands (Hashes): Added
client.hset(),client.hget(), andclient.hgetall(). - Upgraded RESP Parser: The internal parser now supports Integers (
:). hsetreturns anint(1for new field,0for update).hgetallconveniently returns aMap<String, String>.
Fixed #
- Critical Auth Bug: Fixed a bug where
connect()would time out (hang) if authentication failed (e.g., providing a password to a no-auth server). - Test Stability (
FLUSHDB): Fixed flaky command tests (likeHSETreturning0instead of1) by addingFLUSHDBtosetUpAll, ensuring a clean database for each test run. - Test Logic: Fixed the authentication failure test to expect the actual server error message (e.g.,
ERR AUTH) instead of a custom one.
Changed #
- Test Suite: Refactored the entire test setup (
valkey_client_test.dart) to use acheckServerStatus()helper. This reliably checks server availability before defining tests, preventing false skips and cleaning up the test logic.
0.4.0 #
Added #
- Upgraded RESP Parser: Implemented a full recursive parser.
- The parser now supports Arrays (
*), completing the core RESP implementation.
- The parser now supports Arrays (
- New Command: Added
client.mget()(Multiple GET) which relies on the new array parser. - Internal: Refactored the parser logic into a
_BufferReaderfor cleaner, more robust parsing.
0.3.0 #
Added #
- New Commands: Added
client.set()andclient.get()methods. - Upgraded RESP Parser: The internal parser now supports Bulk Strings (
$). - This enables handling standard string values (e.g.,
GET mykey) andnullreplies (e.g.,GET non_existent_key).
0.2.0 #
Added #
- Command Execution Pipeline: Implemented the core
executemethod to send commands and process responses via a queue. - PING Command: Added the first user-facing command:
client.ping(). - Basic RESP Parser: Added an internal parser to handle simple string (
+) and error (-) responses, preparing for full RESP3 support.
0.1.0 #
This is the first functional release, implementing the core connection logic.
Added #
- Core Connection: Implemented the initial client connection logic.
connect(): Connects to the Valkey server.close(): Closes the connection.onConnected: AFuturethat completes when the connection is established.
- Documentation:
- Added public API documentation (
lib/valkey_client.dart). - Added a comprehensive usage example (
example/valkey_client_example.dart).
- Added public API documentation (
- Testing:
- Added unit tests for connection, connection failure, and disconnection scenarios.
0.0.1 #
- Initial version. (Placeholder)