Old values on put call

Anthony Molinaro anthonym at alumni.caltech.edu
Wed May 18 17:28:54 EDT 2011


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                           <anthonym at alumni.caltech.edu>




More information about the riak-users mailing list