Last active
December 25, 2015 19:39
-
-
Save bkerley/7029427 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| map = @bucket.find_crdt 'my-map-key' | |
| map | |
| # alpha: register | |
| # bravo: set | |
| # charlie: map | |
| # charlie.zulu: map | |
| # charlie.zulu.yankee: counter | |
| # delta: counter | |
| map.registers #=> { :alpha => register("123") }, a Collection<Register> which is a kind of Hash | |
| map.registers[:alpha] #=> register("123") | |
| map.registers[:alpha].set "12345" # immediately issues MapOp(update("alpha", "12345")) | |
| map.sets[:bravo] #=> set("abc", "def", "ghi") | |
| map.sets[:bravo].add "abc" # noop? issue MapOp(update("bravo", SetOp(adds: "abc")))? | |
| map.maps[:charlie].maps[:zulu].counters[:yankee].increment # issue MapOp(update("charlie", MapOp(update("zulu", MapOp(update("yankee", CounterOp(1))))))) | |
| map.batch do |m| | |
| m.counters[:delta].increment # enqueue update("delta", CounterOp(1)) on m (which is map in disguise) | |
| m.maps[:charlie].maps[:zulu].flags[:xray] = true # enqueue add("xray", :flag) and update("xray", FlagOp(:enabled)) on m.charlie.zulu (which is map.charlie.zulu in disguise) | |
| end | |
| # issues enqueued updates in single MapOp |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lenary Super thanks for filling me in that map entries are
{name, type} => contentand notname => {type, content}, that helps a ton, especially with the case that somebody puts an entry calledbatchormapordeletein a map.