Hi,
I would just like to ask regarding pre/post commit hooks.
We have a scenario wherein we're aggregating messages into chunks of 20. On a
normal use case, we would usually get the object first, update the value and
then put back to riak.
However we've recently discovered the use of precommit hooks which can actually
manipulate the object before being saved to the database.
As a sample aggregate hook:
precommit_aggregate(Object)->
Bucket = riak_object:bucket(Object),
Key = riak_object:key(Object),
Value = binary_to_term(riak_object:get_value(Object)),
{ok, C} = riak:local_client(),
case C:get(Bucket, Key) of
{ok, BinaryObject} ->
NewValue = riak_object:get_value(BinaryObject) ++ [Value],
riak_object:update_value(BinaryObject, NewValue);
{error,notfound} ->
riak_object:update_value(Object, [Value]);
E->
{fail, E}
end.
Now I've tested this approach on a specific bucket and it works therefore
reducing the calls to riak from 2 to actually just 1. My question is…is this
actually a good approach? Will it become a bottleneck or will it cause problems
eventually? Performance-wise?
--
Byron Wang
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com