dragonflydb / dragonfly

A modern replacement for Redis and Memcached
https://www.dragonflydb.io/
Other
25.65k stars 943 forks source link

implement json.set command #238

Closed romange closed 1 year ago

romange commented 2 years ago

See https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/json-set.html

Furthermore, when using elasticache redis instance:

json.set foo $ '{"a":[], "b":[1], "c":[1,2], "d":[1,2,3]}'
type foo

we get ReJSON-RL similarly, scan 0 type ReJSON-RL should return foo.

Related to #104

romange commented 1 year ago

the first step (PR) will be - to support json object inside CompactObject as a separate tag (JSON_TAG part of TagEnum).

romange commented 1 year ago

it should support creation, destruction, and return a dedicated type via ObjType() access method.

iko1 commented 1 year ago

step zero is merged into the main branch - JSON.SET can set valid data on top of string storage. I think the command should work on string storage when the existing data within the string is valid JSON and of course on the new JSON type that should be implemented in step one.

boazsade commented 1 year ago

The next step should include: New type entry for "CompactObj" inside "union U" (line 332). The new type will be dispatched based on a new entry in TagEnum. This means that this new type cannot be a string type. This object will help not running the json parsing again and again and it must be aligned as size with "RobjWrapper". When a JSON command is dispatched to process value or setting new value, it would lookup or setup the new type that this would create.

boazsade commented 1 year ago

This new entry to compact object - the json type, is not compliant with the format the Redis are saving for JSON (the Redis github for JSON support is here, but we are not going to reference it!).

boazsade commented 1 year ago

This is over for now, we have an internal issue opened on the missing custom allocator that need to be added to jsoncons for this we have a special issue to update the code once the jsoncons is ready. But since the issue for supporting custome allocator is still open, there is no reason to leave this open as well.