Anthony, currently there's no simple way to achieve what you're after. The API is modelled around a GET before you PUT model.
You can specify the option return_body when putting new data into Riak, like so: {ok, RObj} = riak_pb_socket:put (.., NewObject, [return_body]), That returns the freshly written data in the result. It's not exactly what you want, but could be used to achieve what you're after by deliberately creating siblings, by e.g. leaving out the vector clock. Specifying the return_body flag then will return the list of siblings created with this requests. Be aware that abusing this technique with too many writes and not properly reconciling siblings may cause your Riak objects to grow in an unhealthy manner, and it's not exactly a recommended way of doing things. It's an option but certainly not as simple as the one you're after, unless you're prepared to deal with the potential conflicts, and e.g. handle siblings immediately after you reconciled the differences between two objects in your compare() function, see [1] for more details. Mathias Meyer Developer Advocate, Basho Technologies [1] http://wiki.basho.com/Vector-Clocks.html On Mittwoch, 18. Mai 2011 at 23:28, Anthony Molinaro wrote: > Hi, > > I'm working on an application where I am storing an erlang external term > format in riak. The entire structure gets updated at once, but I'd like to > see what is changing, so I have something like this (in pseudo code). > > NewObject = construct_new(...), > OldObject = riak_pb_socket:get(...), > ok = riak_pb_socket:put (.., NewObject), > compare (OldObject, NewObject), > > The idea being that I am updating the object everytime, but I would like > to have a general idea what has changed. > > So I was wondering if there are any options for put to return the previous > value? That would allow me to remove the call to get and simply do something > like. > > NewObject = construct_new(...), > OldObject = riak_pb_socket:put (.., NewObject), > compare (OldObject, NewObject), > > Now I assume what I get back would depend a lot on what the w value is, but > in most cases, I tend to use the defaults. Also, I would think the old > values could be returned as a list in some cases where there was disagreement. > > Anyway, would something like this be hard to implement in riak itself > (it's sort of a specialized use case, but I could see it being useful > in cases like mine where you always want a put to succeed, but you might > want to check what changed for tracking reasons, and I do understand that > you won't be absolutely accurate all the time, but I mostly am looking for > something scalable and mostly accurate). > > -Anthony > > -- > ------------------------------------------------------------------------ > Anthony Molinaro <antho...@alumni.caltech.edu > (mailto:antho...@alumni.caltech.edu)> > > _______________________________________________ > riak-users mailing list > riak-users@lists.basho.com (mailto:riak-users@lists.basho.com) > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com _______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com