dice
dice copied to clipboard
Added SADD, SREM, SMEMBERS, SCARD, SINTER, SDIFF
The changes that are included in the PR.
Added support for the set data structure and related commands as per Redis. The following commands have been added and further more will be added in future PRs.
- SADD
- SREM
- SMEMBERS
- SCARD
- SDIFF
- SINTER
Information on any implementation choices that were made.
I have created a set structure using map since go does not support set as a builtin type. For object encoding, dedicated types have been added for checking object type while mutating the set using commands.
For the commands and their optimization, I have attempted to follow the Redis protocol for these commands in scenarios such as:
- error handling and cases for all scenarios like non-existing key, and invalid type of the object value
- touching the keys even if there is an early return due to optimization incase of SDIFF and SINTER.
- skipping the touch for subsequent keys if we access an object where the type is not SET.
- optimizing the SDIFF and SINTER as per Redis implementation.
Evidence of sufficient testing. You MUST indicate the tests done, either manually or automated. Added new tests for all the scenarios in the tests folder
I have added only six commands as the size of the PR would have been large for just one merge and review. If the implementation looks good, I can pick up other complex commands as well.
If a design document is required, I can create the same. I wanted to get the changes reviewed before spending more time.